Class: Code::Node::Dictionary::KeyValue
- Inherits:
-
Code::Node
- Object
- Code::Node
- Code::Node::Dictionary::KeyValue
- Defined in:
- lib/code/node/dictionary.rb
Instance Method Summary collapse
- #evaluate(**args) ⇒ Object
-
#initialize(parsed) ⇒ KeyValue
constructor
A new instance of KeyValue.
Methods inherited from Code::Node
Constructor Details
#initialize(parsed) ⇒ KeyValue
Returns a new instance of KeyValue.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/code/node/dictionary.rb', line 7 def initialize(parsed) return if parsed.blank? if parsed.key?(:statement) @key = Node::Statement.new(parsed.delete(:statement).presence) elsif parsed.key?(:name) @key = Node::String.new([{ text: parsed.delete(:name).presence }]) end return unless parsed[:value].presence @value = Node::Code.new(parsed.delete(:value).presence) end |