Class: Solve::Artifact
- Inherits:
-
Object
- Object
- Solve::Artifact
- Includes:
- Comparable
- Defined in:
- lib/solve/artifact.rb
Overview
Instance Attribute Summary collapse
-
#graph ⇒ Solve::Graph
readonly
A reference to the graph this artifact belongs to.
-
#name ⇒ String
readonly
The name of the artifact.
-
#version ⇒ Solve::Version
readonly
The version of this artifact.
Instance Method Summary collapse
- #<=>(other) ⇒ Integer
- #==(other) ⇒ Boolean (also: #eql?)
-
#delete ⇒ Solve::Artifact?
Remove this artifact from the graph it belongs to.
-
#dependencies ⇒ Array<Solve::Dependency>
Return the collection of dependencies on this instance of artifact.
-
#depends(name, constraint = ">= 0.0.0") ⇒ Solve::Artifact
Return the Solve::Dependency from the collection of dependencies with the given name and constraint.
-
#get_dependency(name, constraint) ⇒ Solve::Artifact?
Retrieve the dependency from the artifact with the matching name and constraint.
-
#initialize(graph, name, version) ⇒ Artifact
constructor
A new instance of Artifact.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#graph ⇒ Solve::Graph (readonly)
A reference to the graph this artifact belongs to
9 10 11 |
# File 'lib/solve/artifact.rb', line 9 def graph @graph end |
#name ⇒ String (readonly)
The name of the artifact
14 15 16 |
# File 'lib/solve/artifact.rb', line 14 def name @name end |
#version ⇒ Solve::Version (readonly)
The version of this artifact
19 20 21 |
# File 'lib/solve/artifact.rb', line 19 def version @version end |
Instance Method Details
#<=>(other) ⇒ Integer
101 102 103 |
# File 'lib/solve/artifact.rb', line 101 def <=>(other) self.version <=> other.version end |
#==(other) ⇒ Boolean Also known as: eql?
91 92 93 94 95 |
# File 'lib/solve/artifact.rb', line 91 def ==(other) other.is_a?(self.class) && self.name == other.name && self.version == other.version end |
#delete ⇒ Solve::Artifact?
Remove this artifact from the graph it belongs to
76 77 78 79 80 81 82 |
# File 'lib/solve/artifact.rb', line 76 def delete unless graph.nil? result = graph.remove_artifact(self) @graph = nil result end end |
#dependencies ⇒ Array<Solve::Dependency>
Return the collection of dependencies on this instance of artifact
59 60 61 |
# File 'lib/solve/artifact.rb', line 59 def dependencies @dependencies.collect { |name, dependency| dependency } end |
#depends(name, constraint = ">= 0.0.0") ⇒ Solve::Artifact
Return the Solve::Dependency from the collection of dependencies with the given name and constraint.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/solve/artifact.rb', line 45 def depends(name, constraint = ">= 0.0.0") if name.nil? raise ArgumentError, "A name must be specified. You gave: #{args}." end dependency = Dependency.new(self, name, constraint) add_dependency(dependency) self end |
#get_dependency(name, constraint) ⇒ Solve::Artifact?
Retrieve the dependency from the artifact with the matching name and constraint
69 70 71 |
# File 'lib/solve/artifact.rb', line 69 def get_dependency(name, constraint) @dependencies.fetch(Graph.dependency_key(name, constraint), nil) end |
#to_s ⇒ Object
84 85 86 |
# File 'lib/solve/artifact.rb', line 84 def to_s "#{name}-#{version}" end |