Module: VirtualBox::AbstractModel::VersionMatcher
- Included in:
- Attributable, Relatable
- Defined in:
- lib/virtualbox/abstract_model/version_matcher.rb
Instance Method Summary (collapse)
-
- (Object) assert_version_match(req, cur)
Asserts that two versions match.
-
- (Array) split_version(version)
Splits a version string into a two-item array with the parts of the version, respectively.
-
- (Boolean) version_match?(requirement, current)
Checks if a given version requirement matches the current version.
Instance Method Details
- (Object) assert_version_match(req, cur)
Asserts that two versions match. Otherwise raises an exception.
6 7 8 9 10 11 |
# File 'lib/virtualbox/abstract_model/version_matcher.rb', line 6 def assert_version_match(req, cur) if !version_match?(req, cur) = "Required version: #{req}; Current: #{cur}" raise Exceptions::UnsupportedVersionException.new() end end |
- (Array) split_version(version)
Splits a version string into a two-item array with the parts of the version, respectively. If the version has more than two parts, the rest are ignored.
27 28 29 30 31 |
# File 'lib/virtualbox/abstract_model/version_matcher.rb', line 27 def split_version(version) version.split(/\./)[0,2] rescue Exception [] end |
- (Boolean) version_match?(requirement, current)
Checks if a given version requirement matches the current version.
17 18 19 |
# File 'lib/virtualbox/abstract_model/version_matcher.rb', line 17 def version_match?(requirement, current) split_version(requirement) == split_version(current) end |