Class: ActionText::PlainTextConversion::BottomUpReducer

Inherits:
Object
  • Object
show all
Defined in:
lib/action_text/plain_text_conversion.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ BottomUpReducer

Returns a new instance of BottomUpReducer.



127
128
129
130
# File 'lib/action_text/plain_text_conversion.rb', line 127

def initialize(node)
  @node = node
  @values = {}
end

Instance Method Details

#reduce(&block) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/action_text/plain_text_conversion.rb', line 132

def reduce(&block)
  traverse_bottom_up(@node) do |n|
    child_values = @values.values_at(*n.children)
    @values[n] = block.call(n, child_values)
  end
  @values[@node]
end