Class: Composer::Package::LinkConstraint::MultiConstraint
- Inherits:
-
BaseConstraint
- Object
- BaseConstraint
- Composer::Package::LinkConstraint::MultiConstraint
- Defined in:
- lib/composer/package/link_constraint/multi_constraint.rb
Instance Method Summary collapse
-
#initialize(constraints, conjunctive = true) ⇒ MultiConstraint
constructor
Sets operator and version to compare a package with.
- #matches(provider) ⇒ Object
- #pretty_string ⇒ Object
- #pretty_string=(pretty_string) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(constraints, conjunctive = true) ⇒ MultiConstraint
Sets operator and version to compare a package with
19 20 21 22 |
# File 'lib/composer/package/link_constraint/multi_constraint.rb', line 19 def initialize(constraints, conjunctive = true) @constraints = constraints @conjunctive = conjunctive end |
Instance Method Details
#matches(provider) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/composer/package/link_constraint/multi_constraint.rb', line 24 def matches(provider) if @conjunctive === false @constraints.each do |constraint| if constraint.matches(provider) return true end end return false end @constraints.each do |constraint| if !constraint.matches(provider) return false end end true end |
#pretty_string ⇒ Object
47 48 49 50 |
# File 'lib/composer/package/link_constraint/multi_constraint.rb', line 47 def pretty_string return to_s unless @pretty_string @pretty_string end |
#pretty_string=(pretty_string) ⇒ Object
43 44 45 |
# File 'lib/composer/package/link_constraint/multi_constraint.rb', line 43 def pretty_string=(pretty_string) @pretty_string = pretty_string end |
#to_s ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/composer/package/link_constraint/multi_constraint.rb', line 52 def to_s constraints = [] @constraints.each do |constraint| if constraint.is_a?(Array) constraints << String(constraint[0]) else constraints << String(constraint) end end separator = @conjunctive ? ' ' : ' || ' "[#{constraints.join(separator)}]" end |