Class: TreeRepl::NamedNode
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Attributes inherited from TreeNode
Instance Method Summary collapse
-
#find_children ⇒ Object
Creates the children from the provided symbols defined by implementing symbols().
-
#initialize(obj, name) ⇒ NamedNode
constructor
A new instance of NamedNode.
-
#symbols ⇒ Object
-> [symbol] | => symbol.
Methods inherited from TreeNode
Constructor Details
#initialize(obj, name) ⇒ NamedNode
46 47 48 49 |
# File 'lib/treerepl/tree.rb', line 46 def initialize(obj,name) @obj = obj @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/treerepl/tree.rb', line 45 def name @name end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
44 45 46 |
# File 'lib/treerepl/tree.rb', line 44 def obj @obj end |
Instance Method Details
#find_children ⇒ Object
Creates the children from the provided symbols defined by implementing symbols()
53 54 55 56 57 58 59 60 |
# File 'lib/treerepl/tree.rb', line 53 def find_children lst = symbols if lst.is_a? Hash lst.keys.sort.map {|n| CmdNode.new @obj,lst[n],n} else lst.sort {|a,b| a.to_s <=> b.to_s}.map {|n| CmdNode.new @obj,n,nil} end end |
#symbols ⇒ Object
-> [symbol] | => symbol
The symbols (with possible) mapped names to use for children
66 67 68 |
# File 'lib/treerepl/tree.rb', line 66 def symbols raise 'Implement symbols()' end |