Skip to content

Commit d9b912f

Browse files
author
Chris Anderton
committed
naive attempt to fix the implode method on stringable
1 parent 10e6612 commit d9b912f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/treat/entities/entity/stringable.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,29 @@ def inspect
5858
end
5959

6060
# Helper method to implode the string value of the subtree.
61-
def implode
61+
def implode(value = "")
6262

6363
return @value.dup if !has_children?
6464

65-
value = ''
66-
6765
each do |child|
6866

6967
if child.is_a?(Treat::Entities::Section)
70-
value += "\n\n"
68+
value << "\n\n"
7169
end
7270

7371
if child.is_a?(Treat::Entities::Token) || child.value != ''
7472
if child.is_a?(Treat::Entities::Punctuation) ||
7573
child.is_a?(Treat::Entities::Enclitic)
7674
value.strip!
7775
end
78-
value += child.to_s + ' '
76+
value << child.to_s + ' '
7977
else
80-
value += child.implode
78+
child.implode(value)
8179
end
8280

8381
if child.is_a?(Treat::Entities::Title) ||
8482
child.is_a?(Treat::Entities::Paragraph)
85-
value += "\n\n"
83+
value << "\n\n"
8684
end
8785

8886
end

0 commit comments

Comments
 (0)