Class: Belajar::Views::Menu

Inherits:
Object
  • Object
show all
Includes:
Belajar::Views, Wisper::Publisher
Defined in:
lib/belajar/views/menu.rb

Direct Known Subclasses

ChaptersMenu, CoursesMenu, UnitsMenu

Constant Summary collapse

TOP_BAR_TEXT =
[
  'Use * ← * and * → * for menu navigation',
  'Enter menu with * ⏎ *',
  'Go back with * ⟵ *',
  'Exit with *Esc*'
].join('  |  ').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Belajar::Views

#reset_menu_position

Constructor Details

#initializeMenu

Returns a new instance of Menu.



18
19
20
# File 'lib/belajar/views/menu.rb', line 18

def initialize
  @position = 0
end

Instance Attribute Details

#items_info=(value) ⇒ Object

Sets the attribute items_info

Parameters:

  • value

    the value to set the attribute items_info to.



16
17
18
# File 'lib/belajar/views/menu.rb', line 16

def items_info=(value)
  @items_info = value
end

Instance Method Details

#enter(*args) ⇒ Object



22
23
24
25
26
27
28
29
30
# 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) ⇒ Object



32
33
34
35
36
37
38
# 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