class Composer::Semver::Constraint::MultiConstraint
Public Class Methods
new(constraints, conjunctive = true)
click to toggle source
Sets operator and version to compare a package with
@param constraints array A set of constraints @param conjunctive bool Whether the constraints should be treated as conjunctive or disjunctive
# File lib/composer/semver/constraint/multi_constraint.rb, line 19 def initialize(constraints, conjunctive = true) @constraints = constraints @conjunctive = conjunctive end
Public Instance Methods
match_specific?(provider)
click to toggle source
# File lib/composer/semver/constraint/multi_constraint.rb, line 43 def match_specific?(provider) raise ArgumentError, 'The "provider" argument is invalid' unless provider.instance_of?(self.class) matches?(provider) end
matches?(provider)
click to toggle source
# File lib/composer/semver/constraint/multi_constraint.rb, line 24 def matches?(provider) raise ArgumentError, 'The "provider" argument is invalid' unless provider.kind_of?(::Composer::Semver::Constraint::Base) if @conjunctive @constraints.each do |constraint| return false unless constraint.matches?(provider) end true else @constraints.each do |constraint| return true if constraint.matches?(provider) end false end end
to_s()
click to toggle source
# File lib/composer/semver/constraint/multi_constraint.rb, line 51 def to_s constraints = [] unless @constraints.nil? @constraints.each do |constraint| constraints << String(constraint) end end if @conjunctive.nil? separator = ' ' else separator = @conjunctive ? ' ' : ' || ' end "[#{constraints.join(separator)}]" end