Skip to content

Commit

Permalink
naive attempt to fix the implode method on stringable
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Anderton committed Jan 23, 2014
1 parent 10e6612 commit d9b912f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/treat/entities/entity/stringable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,29 @@ def inspect
end

# Helper method to implode the string value of the subtree.
def implode
def implode(value = "")

return @value.dup if !has_children?

value = ''

each do |child|

if child.is_a?(Treat::Entities::Section)
value += "\n\n"
value << "\n\n"
end

if child.is_a?(Treat::Entities::Token) || child.value != ''
if child.is_a?(Treat::Entities::Punctuation) ||
child.is_a?(Treat::Entities::Enclitic)
value.strip!
end
value += child.to_s + ' '
value << child.to_s + ' '
else
value += child.implode
child.implode(value)
end

if child.is_a?(Treat::Entities::Title) ||
child.is_a?(Treat::Entities::Paragraph)
value += "\n\n"
value << "\n\n"
end

end
Expand Down

0 comments on commit d9b912f

Please sign in to comment.