class RedParse::ListInNode::WhenNode
Public Class Methods
new(whenword,when_,thenword,then_)
click to toggle source
Calls superclass method
RedParse::ListInNode::Node::new
# File lib/redparse/node.rb, line 4542 def initialize(whenword,when_,thenword,then_) @offset=whenword.offset when_=Array.new(when_) if CommaOpNode===when_ when_.extend ListInNode if when_.class==Array super(when_,then_) end
Public Instance Methods
image()
click to toggle source
# File lib/redparse/node.rb, line 4552 def image; "(when)" end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 4575 def parsetree(o) conds= if Node|Token===condition [condition.rescue_parsetree(o)] else condition.map{|cond| cond.rescue_parsetree(o)} end if conds.last[0]==:splat conds.last[0]=:when conds.last.push nil end [:when, [:array, *conds], consequent&&consequent.parsetree(o) ] end
to_lisp()
click to toggle source
# File lib/redparse/node.rb, line 4563 def to_lisp unless Node|Token===condition "(when (#{condition.map{|cond| cond.to_lisp}.join(" ")}) #{ consequent&&consequent.to_lisp })" else "(#{when_.to_lisp} #{then_.to_lisp})" end end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 4554 def unparse o=default_unparse_options result=unparse_nl(self,o)+"when " result+=condition.class==Array ? condition.map{|cond| cond.unparse(o)}.join(',') : condition.unparse(o) result+=unparse_nl(consequent,o)+consequent.unparse(o) if consequent result end