module DumbDelimited::InstanceMethods

Public Instance Methods

to_s(eol = false) click to toggle source

Serializes a model object to a delimited string, using the delimiter specified by {ClassMethods#delimiter}. By default, the string will not end with a line terminator. To end the string with a line terminator designated by :row_sep in {ClassMethods#options}, set eol to true.

@param eol [Boolean] @return [String]

# File lib/dumb_delimited.rb, line 321
def to_s(eol = false)
  row_sep = eol ? self.class.options[:row_sep] : -""

  CSV.generate(**self.class.options, row_sep: row_sep, write_headers: false) do |csv|
    csv << self
  end
end