Class: StyleScript::PushNode

Inherits:
Object
  • Object
show all
Defined in:
lib/style_script/nodes.rb

Overview

A faux-node that is never created by the grammar, but is used during code generation to generate a quick “array.push(value)” tree of nodes.

Class Method Summary collapse

Class Method Details

.wrap(array, expressions) ⇒ Object



765
766
767
768
769
770
771
772
# File 'lib/style_script/nodes.rb', line 765

def self.wrap(array, expressions)
  expr = expressions.unwrap
  return expressions if expr.statement_only? || expr.contains? {|n| n.statement_only? }
  Expressions.wrap(CallNode.new(
    ValueNode.new(LiteralNode.new(array), [AccessorNode.new(Value.new('push'))]),
    [expr]
  ))
end