Class: StyleScript::SplatNode

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

Overview

A splat, either as a parameter to a function, an argument to a call, or in a destructuring assignment.

Constant Summary

Constants inherited from Node

Node::TAB

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#children, children, #compile, #compile_closure, #contains?, #idt, statement, #statement?, statement_only, #statement_only?, top_sensitive, #top_sensitive?, #unwrap, #write

Constructor Details

#initialize(name) ⇒ SplatNode

Returns a new instance of SplatNode.



696
697
698
# File 'lib/style_script/nodes.rb', line 696

def initialize(name)
  @name = name
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



694
695
696
# File 'lib/style_script/nodes.rb', line 694

def index
  @index
end

Instance Method Details

#compile_node(o = {}) ⇒ Object



700
701
702
# File 'lib/style_script/nodes.rb', line 700

def compile_node(o={})
  write(@index ? compile_param(o) : @name.compile(o))
end

#compile_param(o) ⇒ Object



704
705
706
707
# File 'lib/style_script/nodes.rb', line 704

def compile_param(o)
  o[:scope].find(@name)
  "#{@name} = Array.prototype.slice.call(arguments, #{@index})"
end

#compile_value(o, name, index) ⇒ Object



709
710
711
# File 'lib/style_script/nodes.rb', line 709

def compile_value(o, name, index)
  "Array.prototype.slice.call(#{name}, #{index})"
end