Class: Solve::Dependency
- Inherits:
-
Object
- Object
- Solve::Dependency
- Defined in:
- lib/solve/dependency.rb
Overview
Instance Attribute Summary collapse
-
#artifact ⇒ Solve::Artifact
readonly
A reference to the artifact this dependency belongs to.
-
#constraint ⇒ Solve::Constraint
readonly
The constraint requirement of this dependency.
-
#name ⇒ String
readonly
The name of the artifact this dependency represents.
Instance Method Summary collapse
- #==(other) ⇒ Boolean (also: #eql?)
-
#delete ⇒ Solve::Dependency?
Remove this dependency from the artifact it belongs to.
-
#initialize(artifact, name, constraint = ">= 0.0.0") ⇒ Dependency
constructor
A new instance of Dependency.
Constructor Details
#initialize(artifact, name, constraint = ">= 0.0.0") ⇒ Dependency
Returns a new instance of Dependency.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/solve/dependency.rb', line 22 def initialize(artifact, name, constraint = ">= 0.0.0") @artifact = artifact @name = name @constraint = case constraint when Solve::Constraint constraint else Constraint.new(constraint) end end |
Instance Attribute Details
#artifact ⇒ Solve::Artifact (readonly)
A reference to the artifact this dependency belongs to
7 8 9 |
# File 'lib/solve/dependency.rb', line 7 def artifact @artifact end |
#constraint ⇒ Solve::Constraint (readonly)
The constraint requirement of this dependency
17 18 19 |
# File 'lib/solve/dependency.rb', line 17 def constraint @constraint end |
#name ⇒ String (readonly)
The name of the artifact this dependency represents
12 13 14 |
# File 'lib/solve/dependency.rb', line 12 def name @name end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
47 48 49 50 51 |
# File 'lib/solve/dependency.rb', line 47 def ==(other) other.is_a?(self.class) && self.artifact == other.artifact && self.constraint == other.constraint end |
#delete ⇒ Solve::Dependency?
Remove this dependency from the artifact it belongs to
36 37 38 39 40 41 42 |
# File 'lib/solve/dependency.rb', line 36 def delete unless artifact.nil? result = artifact.remove_dependency(self) @artifact = nil result end end |