Class: Solve::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/solve/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(artifact, name, constraint = Semverse::DEFAULT_CONSTRAINT) ⇒ Dependency



21
22
23
24
25
# File 'lib/solve/dependency.rb', line 21

def initialize(artifact, name, constraint = Semverse::DEFAULT_CONSTRAINT)
  @artifact   = artifact
  @name       = name
  @constraint = Semverse::Constraint.coerce(constraint)
end

Instance Attribute Details

#artifactSolve::Artifact (readonly)

A reference to the artifact this dependency belongs to



6
7
8
# File 'lib/solve/dependency.rb', line 6

def artifact
  @artifact
end

#constraintSemverse::Constraint (readonly)

The constraint requirement of this dependency



16
17
18
# File 'lib/solve/dependency.rb', line 16

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this dependency represents



11
12
13
# File 'lib/solve/dependency.rb', line 11

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?



34
35
36
37
38
# File 'lib/solve/dependency.rb', line 34

def ==(other)
  other.is_a?(self.class) &&
  self.artifact == other.artifact &&
  self.constraint == other.constraint
end

#to_sObject



27
28
29
# File 'lib/solve/dependency.rb', line 27

def to_s
  "#{name} (#{constraint})"
end