Class: Canis::Utils::MapNode

Inherits:
Object
  • Object
show all
Defined in:
lib/canis/core/widgets/rwidget.rb

Overview

# this allows us to play a bit with the map, and allocate one action to another key # get_action_map() = get_action(32) # But we will hold on this unless absolutely necessary. 2014-05-12 - 22:36 CANIS.

def get_action keycode
  @_key_map[keycode]
end
def get_action_map 
  @_key_map
end

Since:

  • 1.2.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = nil) ⇒ MapNode

Returns a new instance of MapNode.

Since:

  • 1.2.0



516
517
518
# File 'lib/canis/core/widgets/rwidget.rb', line 516

def initialize arg=nil
  @map = Hash.new {|hash, key| hash[key] = MapNode.new }
end

Instance Attribute Details

#actionObject

Since:

  • 1.2.0



514
515
516
# File 'lib/canis/core/widgets/rwidget.rb', line 514

def action
  @action
end

#mapObject

Since:

  • 1.2.0



515
516
517
# File 'lib/canis/core/widgets/rwidget.rb', line 515

def map
  @map
end

Instance Method Details

#fetch(key, deft = nil) ⇒ Object

fetch / get returns a node, or nil. if node, then use node.action

Since:

  • 1.2.0



523
524
525
# File 'lib/canis/core/widgets/rwidget.rb', line 523

def fetch key, deft=nil
  @map.fetch(key, deft)
end

#put(key, value) ⇒ Object

Since:

  • 1.2.0



519
520
521
# File 'lib/canis/core/widgets/rwidget.rb', line 519

def put key, value
  @map[key].action = value
end