Class: StyleScript::SplatNode
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
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
Instance Method Summary collapse
- #compile_node(o = {}) ⇒ Object
- #compile_param(o) ⇒ Object
- #compile_value(o, name, index) ⇒ Object
-
#initialize(name) ⇒ SplatNode
constructor
A new instance of SplatNode.
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
#index ⇒ Object
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 |