Permalink
Browse files

[BUGFIX] Fix #21 on JRuby also

  • Loading branch information...
1 parent e34a2bc commit 097c4f584db07db4dc6e578cad0a724566ef1140 @benlangfeld benlangfeld committed Feb 24, 2014
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/ruby_speech/generic_element.rb
@@ -105,17 +105,16 @@ def +(other)
new_doc = Nokogiri::XML::Document.new
self.class.new(new_doc).tap do |new_element|
new_doc.root = new_element.node
+ string_types = [String, Nokogiri::XML::Text]
+ include_spacing = string_types.include?(self.nokogiri_children.last.class) && string_types.include?(other.nokogiri_children.first.class)
if Nokogiri.jruby?
new_element.add_child self.clone.nokogiri_children
- new_element << " "
+ new_element << " " if include_spacing
new_element.add_child other.clone.nokogiri_children
else
# TODO: This is yucky because it requires serialization
new_element.add_child self.nokogiri_children.to_xml
- string_types = [String, Nokogiri::XML::Text]
- if string_types.include?(self.nokogiri_children.last.class) && string_types.include?(other.nokogiri_children.first.class)
- new_element << " "
- end
+ new_element << " " if include_spacing
new_element.add_child other.nokogiri_children.to_xml
end
end

0 comments on commit 097c4f5

Please sign in to comment.