Class: Twostroke::AST::ObjectLiteral
- Defined in:
- lib/twostroke/ast/object_literal.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
Attributes inherited from Base
Instance Method Summary collapse
- #collapse ⇒ Object
-
#initialize(*args) ⇒ ObjectLiteral
constructor
A new instance of ObjectLiteral.
- #walk(&bk) ⇒ Object
Constructor Details
#initialize(*args) ⇒ ObjectLiteral
Returns a new instance of ObjectLiteral.
5 6 7 8 |
# File 'lib/twostroke/ast/object_literal.rb', line 5 def initialize(*args) @items = [] super *args end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
3 4 5 |
# File 'lib/twostroke/ast/object_literal.rb', line 3 def items @items end |
Instance Method Details
#collapse ⇒ Object
10 11 12 13 |
# File 'lib/twostroke/ast/object_literal.rb', line 10 def collapse collapsed = items.map { |k,v| [k, v.collapse] } self.class.new items: collapsed end |
#walk(&bk) ⇒ Object
15 16 17 18 19 |
# File 'lib/twostroke/ast/object_literal.rb', line 15 def walk(&bk) if yield self items.each { |i| i[1].walk &bk } end end |