Class: CompSci::KeyNode
Overview
adds a key to Node; often the key is used to place the node in the tree, independent of the value; e.g. key=priority, value=process_id
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(val, key: nil, children: []) ⇒ KeyNode
constructor
A new instance of KeyNode.
- #to_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(val, key: nil, children: []) ⇒ KeyNode
Returns a new instance of KeyNode.
41 42 43 44 |
# File 'lib/compsci/node.rb', line 41 def initialize(val, key: nil, children: []) @key = key super(val, children: children) end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
39 40 41 |
# File 'lib/compsci/node.rb', line 39 def key @key end |
Instance Method Details
#to_s ⇒ Object
46 47 48 |
# File 'lib/compsci/node.rb', line 46 def to_s [key, value].join(':') end |