Sha256: 5f8f9e93ed81d78da582d73b328f3ac0fe2efd2e81f3be31bd60eb994849643a

Contents?: true

Size: 666 Bytes

Versions: 4

Compression:

Stored size: 666 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

4 entries across 4 versions & 2 rubygems

Version Path
comma-0.3.2 lib/comma/object.rb
comma-0.3.1 lib/comma/object.rb
liangzan-comma-0.3.1 lib/comma/object.rb
comma-0.3.0 lib/comma/object.rb