Class: Sexp2Ruby::Node::Ensure
- Defined in:
- lib/sexp2ruby/node/ensure.rb
Constant Summary
Constants inherited from Base
Base::ASSIGN_NODES, Base::LF, Base::LINE_LENGTH
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
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 |
# File 'lib/sexp2ruby/node/ensure.rb', line 4 def to_s(exp) body = process exp.shift ens = exp.shift ens = nil if ens == s(:nil) ens = process(ens) || "# do nothing" ens = "begin\n#{ens}\nend\n" if ens =~ /(^|\n)rescue/ body.sub!(/\n\s*end\z/, '') body = indent(body) unless body =~ /(^|\n)rescue/ "#{body}\nensure\n#{indent ens}" end |