lib/X12/Loop.rb in X12-0.0.5 vs lib/X12/Loop.rb in X12-0.1.0

- old
+ new

@@ -21,11 +21,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #++ # module X12 - # $Id: Loop.rb 35 2008-11-13 18:33:44Z ikk $ + # $Id: Loop.rb 59 2009-03-19 22:32:13Z ikk $ # # Implements nested loops of segments class Loop < Base @@ -61,14 +61,18 @@ return s end # parse # Render all components of this loop as string suitable for EDI def render - self.to_a.inject(''){|loop_str, i| - loop_str += i.nodes.inject(''){|nodes_str, j| - nodes_str += j.render - } - } + if self.has_content? + self.to_a.inject(''){|loop_str, i| + loop_str += i.nodes.inject(''){|nodes_str, j| + nodes_str += j.render + } + } + else + '' + end end # render end # Loop end # X12