Sha256: 83126712fc690313ce04713b21779f8c39904e6eb1935f8202fa660ed3605b16

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

module HoneyFormat
  # Default row builder
  class RowBuilder < Struct
    # @return [Struct] returns an instantiated Struct representing a row
    def self.call(row)
      new(*row)
    end

    # @return [String] CSV-string representation.
    def to_csv
      members.map do |column_name|
        column = public_send(column_name)
        if column.respond_to?(:to_csv)
          column.to_csv
        else
          column.to_s
        end
      end.join(',') + "\n"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
honey_format-0.6.0 lib/honey_format/row_builder.rb