Class: DepSelector::VersionConstraint
- Inherits:
-
Object
- Object
- DepSelector::VersionConstraint
- Defined in:
- lib/dep_selector/version_constraint.rb
Constant Summary collapse
- DEFAULT_CONSTRAINT =
">= 0.0.0"
- STANDARD_OPS =
%w(< > <= >=)
- OPS =
%w(< > = <= >= ~>)
- PATTERN =
/^(#{OPS.join('|')}) (.+)$/
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #eql?(o) ⇒ Boolean (also: #==)
- #include?(v) ⇒ Boolean
-
#initialize(constraint_spec = nil) ⇒ VersionConstraint
constructor
A new instance of VersionConstraint.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(constraint_spec = nil) ⇒ VersionConstraint
Returns a new instance of VersionConstraint.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dep_selector/version_constraint.rb', line 31 def initialize(constraint_spec=nil) constraint_spec ||= DEFAULT_CONSTRAINT case constraint_spec when nil parse(DEFAULT_CONSTRAINT) when Array parse_from_array(constraint_spec) when String parse(constraint_spec) else msg = "VersionConstraint should be created from a String. You gave: #{constraint_spec.inspect}" raise Exceptions::InvalidVersionConstraint, msg end end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
29 30 31 |
# File 'lib/dep_selector/version_constraint.rb', line 29 def op @op end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
29 30 31 |
# File 'lib/dep_selector/version_constraint.rb', line 29 def version @version end |
Instance Method Details
#eql?(o) ⇒ Boolean Also known as: ==
63 64 65 |
# File 'lib/dep_selector/version_constraint.rb', line 63 def eql?(o) o.class == self.class && @op == o.op && @version == o.version end |
#include?(v) ⇒ Boolean
46 47 48 49 50 51 52 53 |
# File 'lib/dep_selector/version_constraint.rb', line 46 def include?(v) version = if v.respond_to? :version Version.new(v.version.to_s) else Version.new(v.to_s) end do_op(version) end |
#inspect ⇒ Object
55 56 57 |
# File 'lib/dep_selector/version_constraint.rb', line 55 def inspect "(#{@op} #{@version})" end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/dep_selector/version_constraint.rb', line 59 def to_s "#{@op} #{@version}" end |