Sha256: 144594eba6868fd0c4b45db9016f3caede2728a7bcea3896be7b4f6af0d92c0b

Contents?: true

Size: 660 Bytes

Versions: 9

Compression:

Stored size: 660 Bytes

Contents

class Object
  class_inheritable_accessor :comma_formats

  def self.comma(style = :default, &block)
    (self.comma_formats ||= {})[style] = block
  end

  def to_comma(style = :default)
    raise "No comma format for class #{self.class} defined for style #{style}" unless self.comma_formats and self.comma_formats[style]
    Comma::DataExtractor.new(self, &self.comma_formats[style]).results
  end

  def to_comma_headers(style = :default)
    raise "No comma format for class #{self.class} defined for style #{style}" unless self.comma_formats and self.comma_formats[style]
    Comma::HeaderExtractor.new(self, &self.comma_formats[style]).results
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
comma-2.1.3 lib/comma/object.rb
comma-2.1.2 lib/comma/object.rb
comma-2.1.1 lib/comma/object.rb
comma-2.1 lib/comma/object.rb
comma-2.0 lib/comma/object.rb
comma-0.4.3 lib/comma/object.rb
comma-0.4.2 lib/comma/object.rb
comma-0.4.1 lib/comma/object.rb
comma-0.4.0 lib/comma/object.rb