class DialogTui::Neighbors
Public Class Methods
new(array)
click to toggle source
# File lib/dialog_tui/neighbors.rb, line 4 def initialize array neighbors =\ array.zip( array.rotate, array.rotate(-1) ) keys_values =\ neighbors.map { |entry, nexxt, prev| [ entry, # key { next: nexxt, prev: prev } # value ] } @neighbors_of = Hash[keys_values] end
Public Instance Methods
next(from)
click to toggle source
# File lib/dialog_tui/neighbors.rb, line 19 def next from neighbors(from)[:next] end
prev(from)
click to toggle source
# File lib/dialog_tui/neighbors.rb, line 23 def prev from neighbors(from)[:prev] end
Private Instance Methods
neighbors(entry)
click to toggle source
# File lib/dialog_tui/neighbors.rb, line 28 def neighbors entry @neighbors_of.fetch entry end