Class: RubyCurses::MenuTree
- Inherits:
-
Object
- Object
- RubyCurses::MenuTree
- Defined in:
- lib/rbcurse/extras/widgets/menutree.rb
Overview
Create a simple tree-ish structure. Each node is not a tree, only submenus are trees Others contain a hash with menu character and code Typically the code is not a method symbol, it is to be used to decode a description or method symbol from anoterh hash
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<<(kv) ⇒ Object
- #[](x) ⇒ Object
- #[]=(x, y) ⇒ Object
- #each ⇒ Object
- #each_pair ⇒ Object
- #hash ⇒ Object (also: #children)
-
#initialize(value, hash = {}) ⇒ MenuTree
constructor
A new instance of MenuTree.
- #push(hsh) ⇒ Object
- #submenu(key, value, hash = {}) ⇒ Object
Constructor Details
#initialize(value, hash = {}) ⇒ MenuTree
Returns a new instance of MenuTree.
20 21 22 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 20 def initialize value, hash = {} @value = [value, hash] end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
19 20 21 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 19 def value @value end |
Instance Method Details
#<<(kv) ⇒ Object
23 24 25 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 23 def << kv @value[1][kv[0]] = kv[1] end |
#[](x) ⇒ Object
33 34 35 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 33 def [](x) hash()[x] end |
#[]=(x, y) ⇒ Object
36 37 38 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 36 def []=(x,y) hash()[x] = y end |
#each ⇒ Object
44 45 46 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 44 def each hash().keys.each { |e| yield e } end |
#each_pair ⇒ Object
47 48 49 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 47 def each_pair hash().each_pair { |name, val| yield name, val } end |
#hash ⇒ Object Also known as: children
26 27 28 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 26 def hash @value[1] end |
#push(hsh) ⇒ Object
30 31 32 |
# File 'lib/rbcurse/extras/widgets/menutree.rb', line 30 def push hsh hash().merge hsh end |