class Belajar::Views::Menu
Constants
- TOP_BAR_TEXT
Attributes
items_info[W]
Public Class Methods
new()
click to toggle source
# File lib/belajar/views/menu.rb, line 18 def initialize @position = 0 end
Public Instance Methods
enter(*args)
click to toggle source
# File lib/belajar/views/menu.rb, line 22 def enter(*args) if self.class.private_method_defined?(:before_enter) before_enter(*args) end @window = default_window top_bar = TopBar.new(@window, TOP_BAR_TEXT) show sub_window_below_top_bar(@window, top_bar) end
reenter(*args)
click to toggle source
# File lib/belajar/views/menu.rb, line 32 def reenter(*args) if self.class.private_method_defined?(:before_reenter) before_reenter(*args) end enter(*args) end
Protected Instance Methods
draw(window, active_index = 0)
click to toggle source
# File lib/belajar/views/menu.rb, line 47 def draw(window, active_index = 0) window.attrset(A_NORMAL) window.setpos(0, 1) window.print_markdown(header_text) items.each_with_index do |item, index| window.setpos(index + 2, 1) window.print_indicator(models[index]) window.attrset(index == active_index ? A_STANDOUT : A_NORMAL) window.write " #{item} " window.attrset(A_NORMAL) window.write " #{items_info[index] && items_info[index].join(' ')}" end window.refresh end
header_text()
click to toggle source
# File lib/belajar/views/menu.rb, line 76 def header_text raise 'Please implement the method #header_text!' end
interact_with(window)
click to toggle source
# File lib/belajar/views/menu.rb, line 64 def interact_with(window) raise 'Please implement the method #interact_with!' end
items()
click to toggle source
# File lib/belajar/views/menu.rb, line 72 def items raise 'Please implement the method #items!' end
items_info()
click to toggle source
# File lib/belajar/views/menu.rb, line 80 def items_info @items_info || [] end
models()
click to toggle source
# File lib/belajar/views/menu.rb, line 68 def models raise 'Please implement the method #models!' end
show(window)
click to toggle source
# File lib/belajar/views/menu.rb, line 42 def show(window) draw(window, @position) interact_with(window) end