Class: Solve::Artifact
- Inherits:
-
Object
- Object
- Solve::Artifact
- Includes:
- Comparable
- Defined in:
- lib/solve/artifact.rb
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
8 9 10 |
# File 'lib/solve/artifact.rb', line 8 def graph @graph end |
#name ⇒ String (readonly)
The name of the artifact
13 14 15 |
# File 'lib/solve/artifact.rb', line 13 def name @name end |
#version ⇒ Solve::Version (readonly)
The version of this artifact
18 19 20 |
# File 'lib/solve/artifact.rb', line 18 def version @version end |
Instance Method Details
#<=>(other) ⇒ Integer
100 101 102 |
# File 'lib/solve/artifact.rb', line 100 def <=>(other) self.version <=> other.version end |
#==(other) ⇒ Boolean Also known as: eql?
90 91 92 93 94 |
# File 'lib/solve/artifact.rb', line 90 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
75 76 77 78 79 80 81 |
# File 'lib/solve/artifact.rb', line 75 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
58 59 60 |
# File 'lib/solve/artifact.rb', line 58 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.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solve/artifact.rb', line 44 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
68 69 70 |
# File 'lib/solve/artifact.rb', line 68 def get_dependency(name, constraint) @dependencies.fetch(Graph.dependency_key(name, constraint), nil) end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/solve/artifact.rb', line 83 def to_s "#{name}-#{version}" end |