Class: StyleScript::SliceNode
Overview
An array slice literal. Unlike JavaScript’s Array#slice, the second parameter specifies the index of the end of the slice (just like the first parameter) is the index of the beginning.
Constant Summary
Constants inherited from Node
Instance Method Summary collapse
- #compile_node(o) ⇒ Object
-
#initialize(range) ⇒ SliceNode
constructor
A new instance of SliceNode.
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(range) ⇒ SliceNode
Returns a new instance of SliceNode.
492 493 494 |
# File 'lib/style_script/nodes.rb', line 492 def initialize(range) @range = range end |
Instance Method Details
#compile_node(o) ⇒ Object
496 497 498 499 500 501 |
# File 'lib/style_script/nodes.rb', line 496 def compile_node(o) from = @range.from.compile(o) to = @range.to.compile(o) plus_part = @range.exclusive? ? '' : ' + 1' write(".slice(#{from}, #{to}#{plus_part})") end |