Sha256: 58136b382beda5f7e295927de69a71a838853739e6620265128ba00d9ed41047
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'belajar/views/menu' module Belajar module Views class ChaptersMenu < Menu private def before_enter(*args) @course = args[0] end def before_reenter(*args) @course = args[0] @chapter = args[1] @position = @course.chapters.find_index(@chapter) end def header_text "*#{@course.title}* - available chapters:" end def interact_with(window) while char = window.getch case char when KEY_UP @position -= 1 broadcast(:reset_menu_position) when KEY_DOWN @position += 1 broadcast(:reset_menu_position) when 10 # Enter broadcast(:enter, @course, models[@position]) return when 263 # Backspace broadcast(:reenter, @course) return when 27 # ESC exit end @position = items.length - 1 if @position < 0 @position = 0 if @position >= items.length draw(window, @position) end end def models @course.chapters end def items models.map(&:title) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
belajar-0.1.1 | lib/belajar/views/chapters_menu.rb |