Class: Solve::Dependency

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

Overview

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(artifact, name, constraint = ">= 0.0.0") ⇒ Dependency

Returns a new instance of Dependency.

Parameters:



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

#artifactSolve::Artifact (readonly)

A reference to the artifact this dependency belongs to

Returns:



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

def artifact
  @artifact
end

#constraintSolve::Constraint (readonly)

The constraint requirement of this dependency

Returns:



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

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this dependency represents

Returns:

  • (String)


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

def name
  @name
end

Instance Method Details

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

Parameters:

  • other (Object)

Returns:

  • (Boolean)


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

#deleteSolve::Dependency?

Remove this dependency from the artifact it belongs to

Returns:



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