Sha256: 3be925b01ed3b0fd355ae77438579e2d9e4fb00dd20c28f54fe754b242ec29fa
Contents?: true
Size: 986 Bytes
Versions: 19
Compression:
Stored size: 986 Bytes
Contents
module VirtualBox class AbstractModel module VersionMatcher # Asserts that two versions match. Otherwise raises an # exception. def assert_version_match(req, cur) if !version_match?(req, cur) message = "Required version: #{req}; Current: #{cur}" raise Exceptions::UnsupportedVersionException.new(message) end end # Checks if a given version requirement matches the current # version. # # @return [Boolean] def version_match?(requirement, current) split_version(requirement) == split_version(current) end # 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. # # @param [String] version # @return [Array] def split_version(version) version.split(/\./)[0,2] rescue Exception [] end end end end
Version data entries
19 entries across 19 versions & 3 rubygems