class RedParse::ListInNode::RescueNode
Public Class Methods
new(rescuehdr,action,semi)
click to toggle source
Calls superclass method
RedParse::ListInNode::Node::new
# File lib/redparse/node.rb, line 5227 def initialize(rescuehdr,action,semi) @offset=rescuehdr.offset exlist=rescuehdr.exceptions||[] exlist=[exlist] unless exlist.class==Array fail unless exlist.class==Array exlist.extend ListInNode super(exlist,rescuehdr.varname,action) end
Public Instance Methods
image()
click to toggle source
# File lib/redparse/node.rb, line 5274 def image; "(rescue)" end
parsetree(o)
click to toggle source
# File lib/redparse/node.rb, line 5243 def parsetree(o) result=[:resbody, nil] fail unless exceptions.class==Array ex=#if Node===exceptions; [exceptions.rescue_parsetree(o)] #elsif exceptions exceptions.map{|exc| exc.rescue_parsetree(o)} #end if !ex or ex.empty? #do nothing elsif ex.last.first!=:splat result[1]= [:array, *ex] elsif ex.size==1 result[1]= ex.first else result[1]= [:argscat, ex[0...-1].unshift(:array), ex.last[1]] end VarNode===varname and offset=varname.offset action=if varname SequenceNode.new( AssignNode.new( varname, KeywordToken.new("=",offset), VarNode.new(VarNameToken.new("$!",offset)) ),nil,action() ) else action() end result.push action.parsetree(o) if action result end
unparse(o=default_unparse_options)
click to toggle source
# File lib/redparse/node.rb, line 5237 def unparse o=default_unparse_options xx=exceptions.map{|exc| exc.unparse o}.join(',') unparse_nl(self,o)+ "rescue #{xx} #{varname&&'=> '+varname.lhs_unparse(o)}#{unparse_nl(action||self,o)}#{action&&action.unparse(o)}" end