class About_Pos::Meta
Public Class Methods
new(dir, real_index, arr, prev = nil)
click to toggle source
# File lib/about_pos.rb, line 58 def initialize dir, real_index, arr, prev = nil @arr = arr @data = {} @dir = dir @last_index = arr.size - 1 @real_index = real_index @prev = prev end
Public Instance Methods
[](k)
click to toggle source
# File lib/about_pos.rb, line 75 def [] k @data[@real_index] ||= {} @data[@real_index][k] end
[]=(k, v)
click to toggle source
# File lib/about_pos.rb, line 80 def []= k, v self[k] @data[@real_index][k] = v end
back?()
click to toggle source
# File lib/about_pos.rb, line 168 def back? dir == :back end
bottom?()
click to toggle source
# File lib/about_pos.rb, line 200 def bottom? real_index == last_index end
data()
click to toggle source
# File lib/about_pos.rb, line 67 def data @data end
data=(d)
click to toggle source
# File lib/about_pos.rb, line 71 def data= d @data = d end
dir()
click to toggle source
# File lib/about_pos.rb, line 164 def dir @dir end
dup()
click to toggle source
Calls superclass method
# File lib/about_pos.rb, line 85 def dup d = super d.data= @data d end
forward?()
click to toggle source
# File lib/about_pos.rb, line 172 def forward? dir == :forward end
grab()
click to toggle source
# File lib/about_pos.rb, line 108 def grab raise No_Next, "No more values to grab" unless next? if forward? @real_index += 1 else @real_index -= 1 end value end
middle?()
click to toggle source
# File lib/about_pos.rb, line 196 def middle? real_index != 0 && real_index != last_index end
next()
click to toggle source
# File lib/about_pos.rb, line 118 def next m = dup m.next! m end
next!()
click to toggle source
# File lib/about_pos.rb, line 130 def next! @msg ||= if forward? "This is the last position." else "This is the first position." end raise No_Next, @msg if !next? if forward? @real_index = @real_index + 1 else @real_index = @real_index - 1 end value end
next?()
click to toggle source
# File lib/about_pos.rb, line 176 def next? if forward? real_index < last_index else real_index > 0 end end
prev()
click to toggle source
# File lib/about_pos.rb, line 124 def prev m = dup m.prev! m end
prev!()
click to toggle source
# File lib/about_pos.rb, line 147 def prev! @msg ||= if forward? "This is the first position." else "This is the last position." end raise No_Prev, @msg if !prev? if forward? @real_index = real_index - 1 else @real_index = real_index + 1 end value end
prev?()
click to toggle source
# File lib/about_pos.rb, line 184 def prev? if forward? real_index > 0 else real_index < last_index end end
top?()
click to toggle source
# File lib/about_pos.rb, line 192 def top? real_index == 0 end
value()
click to toggle source
# File lib/about_pos.rb, line 91 def value arr[real_index] end