class ScreenManager

Public Class Methods

new() click to toggle source
# File lib/delve/screen_manager.rb, line 2
def initialize
  @screen_stack = Array.new
end

Public Instance Methods

empty?() click to toggle source
# File lib/delve/screen_manager.rb, line 6
def empty?
  @screen_stack.empty?
end
pop_screen() click to toggle source
# File lib/delve/screen_manager.rb, line 14
def pop_screen
  @screen_stack.pop
end
push_screen(screen) click to toggle source
# File lib/delve/screen_manager.rb, line 10
def push_screen(screen)
  @screen_stack.push screen
end
render(display) click to toggle source
# File lib/delve/screen_manager.rb, line 24
def render(display)
  raise 'Cannot render when no screens are present' if empty?
  raise 'Cannot render when display is nil' unless display

  bottom = @screen_stack.length - 1
  screens = @screen_stack.length - 1
  
  (0..screens).reverse_each do |i|
    if !@screen_stack[i].partial?
      break
    end
    bottom = i-1
  end
  (bottom..screens).each do |i|
    @screen_stack[i].render display
  end
end
update(input) click to toggle source
# File lib/delve/screen_manager.rb, line 18
def update(input)
  raise 'Cannot handle key when no screens are present' if empty?
  raise 'Cannot handle key when input is nil' unless input
  @screen_stack.last.update input
end