Class: Soroban::LabelWalker
- Inherits:
-
Object
- Object
- Soroban::LabelWalker
- Includes:
- Enumerable
- Defined in:
- lib/soroban/label_walker.rb
Overview
An enumerable that allows cells in a range to be visited.
Instance Method Summary (collapse)
-
- (Object) each
Yield the label of each cell referenced by the supplied range.
-
- (LabelWalker) initialize(range)
constructor
Create a new walker from a supplied range.
Constructor Details
- (LabelWalker) initialize(range)
Create a new walker from a supplied range.
9 10 11 |
# File 'lib/soroban/label_walker.rb', line 9 def initialize(range) @fc, @fr, @tc, @tr = Soroban::getRange(range) end |
Instance Method Details
- (Object) each
Yield the label of each cell referenced by the supplied range.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/soroban/label_walker.rb', line 14 def each col, row = @fc, @fr while true do yield "#{col}#{row}" break if row == @tr && col == @tc if row == @tr row = @fr col = col.next else row = row.next end end end |