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

Returns a new instance of Dependency.

Parameters:

  • artifact (Solve::Artifact)
  • name (#to_s)
  • constraint (Semverse::Constraint, #to_s) (defaults to: Semverse::DEFAULT_CONSTRAINT)


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

Returns:



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

def artifact
  @artifact
end

#constraintSemverse::Constraint (readonly)

The constraint requirement of this dependency

Returns:

  • (Semverse::Constraint)


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

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this dependency represents

Returns:

  • (String)


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

def name
  @name
end

Instance Method Details

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

Parameters:

  • other (Object)

Returns:

  • (Boolean)


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