Class: Composer::Semver::Constraint::MultiConstraint
- Inherits:
-
Base
- Object
- Base
- Composer::Semver::Constraint::MultiConstraint
show all
- Defined in:
- lib/composer/semver/constraint/multi_constraint.rb
Instance Method Summary
collapse
Methods inherited from Base
#pretty_string, #pretty_string=
Constructor Details
#initialize(constraints, conjunctive = true) ⇒ MultiConstraint
Sets operator and version to compare a package with
19
20
21
22
|
# File 'lib/composer/semver/constraint/multi_constraint.rb', line 19
def initialize(constraints, conjunctive = true)
@constraints = constraints
@conjunctive = conjunctive
end
|
Instance Method Details
#match_specific?(provider) ⇒ Boolean
43
44
45
46
47
48
49
|
# 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) ⇒ Boolean
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# 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 ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# 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
|