Class: Code::Node::DictionnaryKeyValue
- Inherits:
-
Object
- Object
- Code::Node::DictionnaryKeyValue
- Defined in:
- lib/code/node/dictionnary_key_value.rb
Instance Method Summary collapse
- #evaluate(context) ⇒ Object
-
#initialize(key_value) ⇒ DictionnaryKeyValue
constructor
A new instance of DictionnaryKeyValue.
Constructor Details
#initialize(key_value) ⇒ DictionnaryKeyValue
Returns a new instance of DictionnaryKeyValue.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/code/node/dictionnary_key_value.rb', line 4 def initialize(key_value) @key = key_value.fetch(:key) if @key.is_a?(Array) @key = ::Code::Node::Code.new(@key) elsif @key.key?(:name) @key = ::Code::Node::String.new(@key[:name]) else @key = ::Code::Node::Statement.new(@key) end @value = ::Code::Node::Code.new(key_value.fetch(:value)) end |
Instance Method Details
#evaluate(context) ⇒ Object
18 19 20 |
# File 'lib/code/node/dictionnary_key_value.rb', line 18 def evaluate(context) [@key.evaluate(context), @value.evaluate(context)] end |