Class: Amrita::PreFormatter

Class Amrita::PreFormatter |
In: | lib/amrita/format.rb
Parent: | Object

Methods

<< new pre_format result result_as_top

Attributes

:expand_attr | [R] |
:formatter | [R] |

Public Class methods

new(formatter, expand_attr=false)

    # File lib/amrita/format.rb, line 465
        def initialize(formatter, expand_attr=false)
          @formatter = formatter
          @expand_attr = expand_attr
          @result_str = ""
          @result_array = []
        end

Public Instance methods

pre_format(node)

    # File lib/amrita/format.rb, line 472
        def pre_format(node)
          @formatter.with_stream(self) do
            node.pre_format1(self)
          end
        end

<<(x)

    # File lib/amrita/format.rb, line 478
        def <<(x)
          case x
          when Element
            @result_array << SanitizedString[@result_str] unless @result_str == ""
            @result_array << x
            @result_str = ""
          when String
            @result_str << x
          when NodeArray
            x.array.each do |n|
              n.pre_format1(self)
            end
          when Node
            @formatter.format(x)
          else
            @result_str << x.to_s
          end
          self
        end

result()

    # File lib/amrita/format.rb, line 498
        def result
          @result_array << SanitizedString[@result_str] unless @result_str == ""
          case @result_array.size
          when 0
            Null
          when 1
            @result_array[0]
          else
            @result_array
          end
        end

result_as_top()

    # File lib/amrita/format.rb, line 510
        def result_as_top
          Node::to_node(result)
        end