lib/soroban/label_walker.rb in soroban-0.7.3 vs lib/soroban/label_walker.rb in soroban-0.8.0
- old
+ new
@@ -1,30 +1,31 @@
+require 'soroban/helpers'
+
module Soroban
- # An enumerable that allows cells in a range to be visited.
+ # An enumerable that allows the labels for cells in a range to be visited.
class LabelWalker
-
include Enumerable
# Create a new walker from a supplied range.
def initialize(range)
- @fc, @fr, @tc, @tr = Soroban::getRange(range)
+ @_fc, @_fr, @_tc, @_tr = Soroban::Helpers.getRange(range)
end
- # Yield the label of each cell referenced by the supplied range.
+ # Yield the label of each cell referenced by the supplied range. For a range
+ # of the form "A1:B4", this will yield "A1", "A2", "A3", ..., "B3", "B4".
def each
- col, row = @fc, @fr
+ col, row = @_fc, @_fr
while true do
yield "#{col}#{row}"
- break if row == @tr && col == @tc
- if row == @tr
- row = @fr
+ break if row == @_tr && col == @_tc
+ if row == @_tr
+ row = @_fr
col = col.next
else
row = row.next
end
end
end
-
end
end