Class: Knossos::Solver::Distances
- Inherits:
-
Object
- Object
- Knossos::Solver::Distances
- Defined in:
- lib/knossos/solver/distances.rb
Instance Method Summary collapse
- #[](cell) ⇒ Object
- #[]=(cell, distance) ⇒ Object
- #cells ⇒ Object
-
#initialize(root:) ⇒ Distances
constructor
A new instance of Distances.
- #max ⇒ Object
Constructor Details
Instance Method Details
#[](cell) ⇒ Object
10 11 12 |
# File 'lib/knossos/solver/distances.rb', line 10 def [](cell) @cells[cell] end |
#[]=(cell, distance) ⇒ Object
14 15 16 |
# File 'lib/knossos/solver/distances.rb', line 14 def []=(cell, distance) @cells[cell] = distance end |
#cells ⇒ Object
18 19 20 |
# File 'lib/knossos/solver/distances.rb', line 18 def cells @cells.keys end |
#max ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/knossos/solver/distances.rb', line 22 def max max_distance = 0 max_cell = @root @cells.each do |cell, distance| if distance > max_distance max_cell = cell max_distance = distance end end [max_cell, max_distance] end |