Class: DepSelector::Dependency

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

Direct Known Subclasses

SolutionConstraint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, constraint = nil) ⇒ Dependency

Returns a new instance of Dependency.



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

def initialize(package, constraint=nil)
  @package = package
  @constraint = constraint || VersionConstraint.new
end

Instance Attribute Details

#constraintObject (readonly)

Returns the value of attribute constraint.



24
25
26
# File 'lib/dep_selector/dependency.rb', line 24

def constraint
  @constraint
end

#packageObject (readonly)

Returns the value of attribute package.



24
25
26
# File 'lib/dep_selector/dependency.rb', line 24

def package
  @package
end

Instance Method Details

#==(o) ⇒ Object



36
37
38
39
# File 'lib/dep_selector/dependency.rb', line 36

def ==(o)
  o.respond_to?(:package) && package == o.package &&
    o.respond_to?(:constraint) && constraint == o.constraint
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/dep_selector/dependency.rb', line 41

def eql?(o)
  self.class == o.class && self == o
end

#to_s(incl_densely_packed_versions = false) ⇒ Object



31
32
33
34
# File 'lib/dep_selector/dependency.rb', line 31

def to_s(incl_densely_packed_versions = false)
  range = package.densely_packed_versions[constraint]
  "(#{package.name} #{constraint.to_s}#{incl_densely_packed_versions ? " (#{range})" : ''})"
end