Class: DepSelector::PackageVersion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, version) ⇒ PackageVersion

Returns a new instance of PackageVersion.



24
25
26
27
28
# File 'lib/dep_selector/package_version.rb', line 24

def initialize(package, version)
  @package = package
  @version = version
  @dependencies = []
end

Instance Attribute Details

#dependenciesObject

Returns the value of attribute dependencies.



22
23
24
# File 'lib/dep_selector/package_version.rb', line 22

def dependencies
  @dependencies
end

#packageObject

Returns the value of attribute package.



22
23
24
# File 'lib/dep_selector/package_version.rb', line 22

def package
  @package
end

#versionObject

Returns the value of attribute version.



22
23
24
# File 'lib/dep_selector/package_version.rb', line 22

def version
  @version
end

Instance Method Details

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

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/dep_selector/package_version.rb', line 55

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

#generate_gecode_wrapper_constraintsObject



30
31
32
33
34
35
36
37
# File 'lib/dep_selector/package_version.rb', line 30

def generate_gecode_wrapper_constraints
  pkg_densely_packed_version = package.densely_packed_versions.index(version)

  dependencies.each do |dep|
    dep_pkg_range = dep.package.densely_packed_versions[dep.constraint]
    package.dependency_graph.gecode_wrapper.add_version_constraint(package.gecode_package_id, pkg_densely_packed_version, dep.package.gecode_package_id, dep_pkg_range.min, dep_pkg_range.max)
  end
end

#hashObject



49
50
51
52
53
# File 'lib/dep_selector/package_version.rb', line 49

def hash
  # Didn't put any thought or research into this, probably can be
  # done better
  to_s.hash
end

#to_hashObject



63
64
65
# File 'lib/dep_selector/package_version.rb', line 63

def to_hash
  { :package_name => package.name, :version => version }
end

#to_s(incl_densely_packed_versions = false) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/dep_selector/package_version.rb', line 39

def to_s(incl_densely_packed_versions = false)
  components = []
  components << "#{version}"
  if incl_densely_packed_versions
    components << " (#{package.densely_packed_versions.index(version)})"
  end
  components << " -> [#{dependencies.map{|d|d.to_s(incl_densely_packed_versions)}.join(', ')}]"
  components.join
end