Class: Sexp2Ruby::Node::Resbody

Inherits:
Base
  • Object
show all
Defined in:
lib/sexp2ruby/node/resbody.rb

Constant Summary

Constants inherited from Base

Base::ASSIGN_NODES, Base::LF, Base::LINE_LENGTH

Instance Attribute Summary

Attributes inherited from Base

#processor

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Sexp2Ruby::Node::Base

Instance Method Details

#to_s(exp) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sexp2ruby/node/resbody.rb', line 4

def to_s(exp)
  args = exp.shift
  body = finish(exp)
  body << "# do nothing" if body.empty?

  name =   args.lasgn true
  name ||= args.iasgn true
  args = process(args)[1..-2]
  args = " #{args}" unless args.empty?
  args += " => #{name[1]}" if name

  "rescue#{args}\n#{indent body.join(LF)}"
end