Class: Halunke::DictionaryNode
- Inherits:
-
Struct
- Object
- Struct
- Halunke::DictionaryNode
- Defined in:
- lib/halunke/nodes.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#te ⇒ Object
Returns the value of attribute te.
-
#ts ⇒ Object
Returns the value of attribute ts.
Instance Method Summary collapse
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes
112 113 114 |
# File 'lib/halunke/nodes.rb', line 112 def nodes @nodes end |
#te ⇒ Object
Returns the value of attribute te
112 113 114 |
# File 'lib/halunke/nodes.rb', line 112 def te @te end |
#ts ⇒ Object
Returns the value of attribute ts
112 113 114 |
# File 'lib/halunke/nodes.rb', line 112 def ts @ts end |
Instance Method Details
#==(other) ⇒ Object
123 124 125 126 |
# File 'lib/halunke/nodes.rb', line 123 def ==(other) other.is_a?(DictionaryNode) && nodes == other.nodes end |
#eval(context) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/halunke/nodes.rb', line 113 def eval(context) hash = {} nodes.each_slice(2) do |key, value| raise HInvalidDictionary.new("This key has no value", key.source_code_position) if value.nil? hash[key.eval(context)] = value.eval(context) end context["Dictionary"].create_instance(hash, source_code_position: source_code_position) end |
#source_code_position ⇒ Object
128 129 130 |
# File 'lib/halunke/nodes.rb', line 128 def source_code_position SourceCodePosition.new(ts, te) end |