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 = ">= 0.0.0") ⇒ Dependency

Returns a new instance of Dependency.

Parameters:



21
22
23
24
25
26
27
28
29
30
# File 'lib/solve/dependency.rb', line 21

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:



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

def artifact
  @artifact
end

#constraintSolve::Constraint (readonly)

The constraint requirement of this dependency

Returns:



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)


46
47
48
49
50
# File 'lib/solve/dependency.rb', line 46

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:



35
36
37
38
39
40
41
# File 'lib/solve/dependency.rb', line 35

def delete
  unless artifact.nil?
    result = artifact.remove_dependency(self)
    @artifact = nil
    result
  end
end