Class: Sexp2Ruby::Node::For

Inherits:
Base
  • Object
show all
Defined in:
lib/sexp2ruby/node/for.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
# File 'lib/sexp2ruby/node/for.rb', line 4

def to_s(exp)
  recv = process exp.shift
  iter = process exp.shift
  body = exp.empty? ? nil : process(exp.shift)

  result = ["for #{iter} in #{recv} do"]
  result << indent(body ? body : "# do nothing")
  result << "end"

  result.join(LF)
end