Class: RequestMigrations::Version::Constraint

Inherits:
Object
  • Object
show all
Defined in:
lib/request_migrations/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(constraint) ⇒ Constraint

Returns a new instance of Constraint.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/request_migrations/version.rb', line 49

def initialize(constraint)
  @format     = RequestMigrations.config.version_format.to_sym
  @constraint = case @format
                when :semver
                  Semverse::Constraint.coerce(constraint)
                when :date,
                     :integer,
                     :float,
                     :string
                  raise NotImplementedError, "#{@format} constraints are not supported"
                else
                  raise InvalidVersionFormatError, "invalid version constraint format: #{@format} (must be one of: #{SUPPORTED_VERSION_FORMATS.join(',')}"
                end
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



46
47
48
# File 'lib/request_migrations/version.rb', line 46

def format
  @format
end

#valueObject (readonly)

Returns the value of attribute value.



46
47
48
# File 'lib/request_migrations/version.rb', line 46

def value
  @value
end

Instance Method Details

#satisfies?(other) ⇒ Boolean

Returns:

  • (Boolean)


64
# File 'lib/request_migrations/version.rb', line 64

def satisfies?(other) = @constraint.satisfies?(other)