class Composer::Package::LinkConstraint::MultiConstraint

Public Class Methods

new(constraints, conjunctive = true) click to toggle source

Sets operator and version to compare a package with @param array $constraints A set of constraints @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive

# File lib/composer/package/link_constraint/multi_constraint.rb, line 19
def initialize(constraints, conjunctive = true)
  @constraints = constraints
  @conjunctive = conjunctive
end

Public Instance Methods

matches(provider) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# File lib/composer/package/link_constraint/multi_constraint.rb, line 43
def pretty_string=(pretty_string)
  @pretty_string = pretty_string
end
to_s() click to toggle source
# 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