Class: Object

Inherits:
BasicObject
Defined in:
lib/comma.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.comma(style = :default, &block) ⇒ Object



20
21
22
# File 'lib/comma.rb', line 20

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

Instance Method Details

#to_comma(style = :default) ⇒ Object



24
25
26
27
# File 'lib/comma.rb', line 24

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

#to_comma_headers(style = :default) ⇒ Object



29
30
31
32
# File 'lib/comma.rb', line 29

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