Class: StyleScript::ReturnNode

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

Overview

Return an expression, or wrap it in a closure and return it.

Constant Summary

Constants inherited from Node

Node::TAB

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(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