Class: Sexp2Ruby::Node::Block

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

Constant Summary

Constants inherited from Base

Sexp2Ruby::Node::Base::ASSIGN_NODES, Sexp2Ruby::Node::Base::LF, Sexp2Ruby::Node::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
17
18
19
20
21
# File 'lib/sexp2ruby/node/block.rb', line 4

def to_s(exp)
  result = []

  exp << nil if exp.empty?
  until exp.empty? do
    code = exp.shift
    if code.nil? or code.first == :nil
      result << "# do nothing\n"
    else
      result << process(code)
    end
  end

  result = parenthesize result.join LF
  result += LF unless result.start_with? "("

  result
end