Class: Luoma::ObjectLiteral
- Inherits:
-
Expression
- Object
- Expression
- Luoma::ObjectLiteral
- Defined in:
- lib/luoma/expression.rb,
sig/luoma/expression.rbs
Instance Attribute Summary
Attributes inherited from Expression
Instance Method Summary collapse
- #children ⇒ Object
- #evaluate(context) ⇒ Object
-
#initialize(token, items) ⇒ ObjectLiteral
constructor
(t_token token, Array items) -> void.
- #to_s ⇒ Object
- #with(token) ⇒ self
Methods inherited from Expression
Constructor Details
#initialize(token, items) ⇒ ObjectLiteral
(t_token token, Array items) -> void
940 941 942 943 |
# File 'lib/luoma/expression.rb', line 940 def initialize(token, items) super(token) @items = items end |
Instance Method Details
#children ⇒ Object
960 961 962 |
# File 'lib/luoma/expression.rb', line 960 def children @items end |
#evaluate(context) ⇒ Object
946 947 948 949 950 951 952 953 954 955 956 957 958 |
# File 'lib/luoma/expression.rb', line 946 def evaluate(context) result = {} #: Hash[String, untyped] @items.each do |item| if item.is_a?(Spread) result.update(context.env.to_h(item.expr.evaluate(context), context)) else result[item.key.value] = item.expr.evaluate(context) end end result end |
#to_s ⇒ Object
965 966 967 |
# File 'lib/luoma/expression.rb', line 965 def to_s "{#{@items.join(", ")}}" end |