class Daigaku::Views::UnitsMenu
Private Instance Methods
before_enter(*args)
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 8 def before_enter(*args) @course = args[0] @chapter = args[1] end
before_reenter(*args)
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 13 def before_reenter(*args) @course = args[0] @chapter = args[1] @unit = args[2] @position = @chapter.units.find_index(@unit) end
header_text()
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 20 def header_text "*#{@course.title}* > *#{@chapter.title}* - available units:" end
interact_with(window)
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 24 def interact_with(window) while char = window.getch case char when KEY_UP @position -= 1 when KEY_DOWN @position += 1 when 10 # Enter broadcast(:enter, @course, @chapter, models[@position]) return when 263 # Backspace broadcast(:reenter, @course, @chapter) return when 27 # ESC exit end @position = items.length - 1 if @position < 0 @position = 0 if @position >= items.length draw(window, @position) end end
items()
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 51 def items models.map(&:title) end
models()
click to toggle source
# File lib/daigaku/views/units_menu.rb, line 47 def models @chapter.units end