naive attempt to fix the implode method on stringable

This commit is contained in:
Chris Anderton 2014-01-23 00:57:32 +00:00
parent 10e6612a06
commit d9b912f24d
1 changed files with 5 additions and 7 deletions

View File

@ -58,16 +58,14 @@ module Treat::Entities::Entity::Stringable
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 != ''
@ -75,14 +73,14 @@ module Treat::Entities::Entity::Stringable
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