Class: Doubleshot::Resolver::GemResolver::Demand

Inherits:
Object
  • Object
show all
Defined in:
lib/doubleshot/resolver/gem_resolver/demand.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solver, name, constraint = ">= 0") ⇒ Demand

Returns a new instance of Demand.

Parameters:



23
24
25
26
27
28
29
30
31
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 23

def initialize(solver, name, constraint = ">= 0")
  @solver = solver
  @name = name
  @constraint = if constraint.is_a?(Gem::Requirement)
    constraint
  else
    Gem::Requirement.new(constraint.to_s)
  end
end

Instance Attribute Details

#constraintGem::Requirement (readonly)

The acceptable constraint of the artifact this demand is for

Returns:



18
19
20
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 18

def constraint
  @constraint
end

#nameString (readonly)

The name of the artifact this demand is for

Returns:



13
14
15
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 13

def name
  @name
end

#solverDoubleshot::Resolver::GemResolver::Solver (readonly)

A reference to the solver this demand belongs to



8
9
10
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 8

def solver
  @solver
end

Instance Method Details

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



48
49
50
51
52
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 48

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

#deleteDoubleshot::Resolver::GemResolver::Demand?

Remove this demand from the solver it belongs to



36
37
38
39
40
41
42
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 36

def delete
  unless solver.nil?
    result = solver.remove_demand(self)
    @solver = nil
    result
  end
end

#to_sObject



44
45
46
# File 'lib/doubleshot/resolver/gem_resolver/demand.rb', line 44

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