Class: NScript::SliceNode
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.
420 421 422 |
# File 'lib/nscript/parser/nodes.rb', line 420 def initialize(range) @range = range end |
Instance Method Details
#compile_node(o) ⇒ Object
424 425 426 427 428 429 |
# File 'lib/nscript/parser/nodes.rb', line 424 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 |