Class: StyleScript::ReturnNode
Overview
Return an expression, or wrap it in a closure and return it.
Constant Summary
Constants inherited from Node
Instance Method Summary collapse
- #compile_node(o) ⇒ Object
-
#initialize(expression) ⇒ ReturnNode
constructor
A new instance of ReturnNode.
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(expression) ⇒ ReturnNode
Returns a new instance of ReturnNode.
218 219 220 |
# File 'lib/style_script/nodes.rb', line 218 def initialize(expression) @expression = expression end |
Instance Method Details
#compile_node(o) ⇒ Object
222 223 224 225 226 |
# File 'lib/style_script/nodes.rb', line 222 def compile_node(o) return write(@expression.compile(o.merge(:return => true))) if @expression.statement? compiled = @expression.compile(o) write("#{idt}return #{compiled};") end |