class HandyToolbox::Navigator

Public Instance Methods

current_parent() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 33
def current_parent
  @parent
end
down(by = 1) click to toggle source
# File lib/handy_toolbox/navigator.rb, line 59
def down(by = 1)
  @current_index = [@current_index + by, @children.size - 1].min
end
enter(parent) click to toggle source
# File lib/handy_toolbox/navigator.rb, line 46
def enter(parent)
  @parent = parent
  parent.on_load if parent.is_a?(MenuLoader)

  @children = parent.children
  @current_index = 0
  selection
end
enter_selected() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 37
def enter_selected
  old = selection
  if selection.id == Ids::BACK
    enter(old.parent)
  else
    enter(selection)
  end
end
select_by_index(index) click to toggle source
# File lib/handy_toolbox/navigator.rb, line 27
def select_by_index(index)
  if index >= 0 && index < @children.size
    @current_index = index
  end
end
select_first() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 19
def select_first
  select_by_index(0)
end
select_last() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 23
def select_last
  select_by_index(@children.size - 1)
end
selection() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 15
def selection
  @children[@current_index]
end
tool() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 9
def tool
  if tool_selected?
    selection.tool
  end
end
tool_selected?() click to toggle source
# File lib/handy_toolbox/navigator.rb, line 5
def tool_selected?
  selection.is_a?(ToolMenuItem)
end
up(by = 1) click to toggle source
# File lib/handy_toolbox/navigator.rb, line 55
def up(by = 1)
  @current_index = [0, @current_index - by].max
end