lib/io_streams/tabular/parser/psv.rb in iostreams-1.1.0 vs lib/io_streams/tabular/parser/psv.rb in iostreams-1.1.1

- old
+ new

@@ -10,30 +10,28 @@ unless row.is_a?(String) raise(IOStreams::Errors::InvalidHeader, "Format is :psv. Invalid input header: #{row.class.name}") end - row.split('|') + row.split("|") end # Returns [Array] the parsed PSV line def parse(row) return row if row.is_a?(::Array) - unless row.is_a?(String) - raise(IOStreams::Errors::TypeMismatch, "Format is :psv. Invalid input: #{row.class.name}") - end + raise(IOStreams::Errors::TypeMismatch, "Format is :psv. Invalid input: #{row.class.name}") unless row.is_a?(String) - row.split('|') + row.split("|") end # Return the supplied array as a single line JSON string. def render(row, header) array = header.to_array(row) cleansed_array = array.collect do |i| - i.is_a?(String) ? i.tr('|', ':') : i + i.is_a?(String) ? i.tr("|", ":") : i end - cleansed_array.join('|') + cleansed_array.join("|") end end end end end