# File lib/sup/horizontal-selector.rb, line 6 def initialize label, vals, labels, base_color=:horizontal_selector_unselected_color, selected_color=:horizontal_selector_selected_color @label = label @vals = vals @labels = labels @base_color = base_color @selected_color = selected_color @selection = 0 end
# File lib/sup/horizontal-selector.rb, line 19 def line width=nil label = if width sprintf "%#{width}s ", @label else "#{@label} " end [[@base_color, label]] + (0 ... @labels.length).inject([]) do |array, i| array + [ if i == @selection [@selected_color, @labels[i]] else [@base_color, @labels[i]] end] + [[@base_color, " "]] end + [[@base_color, ""]] end
# File lib/sup/horizontal-selector.rb, line 38 def roll_left @selection = (@selection - 1) % @labels.length end
# File lib/sup/horizontal-selector.rb, line 42 def roll_right @selection = (@selection + 1) % @labels.length end
Generated with the Darkfish Rdoc Generator 2.