class LanguageCards::MenuNode

Attributes

child[R]
name[R]

Public Class Methods

new(name, child) click to toggle source
# File lib/language_cards/menu_node.rb, line 4
def initialize name, child
  @name = name

  if child.is_a?(Hash) and child.has_key?("mapping")
    @mapping = child.delete("mapping") # Extra unused data for the moment
    @child = CardSet.new(child)
  else
    @child = MenuNode.new(*child)
  end
end

Public Instance Methods

label() click to toggle source

This is the preferred method for the view as this object shouldn't care about how it should be displayed in the view. @return Array<String>

# File lib/language_cards/menu_node.rb, line 27
def label
  [@name].push(*child.label)
end
mode(game_mode) click to toggle source

@return <Mode<CardSet> < Game>

# File lib/language_cards/menu_node.rb, line 20
def mode(game_mode)
  child.mode(game_mode)
end
title(fmt = ' - ', rng = 0..-1) click to toggle source
# File lib/language_cards/menu_node.rb, line 15
def title(fmt = ' - ', rng = 0..-1)
  label[rng].delete_if(&:empty?).join(fmt)
end
to_s() click to toggle source
# File lib/language_cards/menu_node.rb, line 31
def to_s
  label.delete_if(&:empty?).join(' - ')
end