class Smuggle::Exporter::Base
Attributes
attribute_labels[W]
attributes[W]
Public Class Methods
attribute_labels(labels)
click to toggle source
# File lib/smuggle/exporter/base.rb, line 23 def attribute_labels(labels) @attribute_labels.merge!(labels) end
attribute_labels?()
click to toggle source
# File lib/smuggle/exporter/base.rb, line 27 def attribute_labels? @attribute_labels.any? end
attributes(*names)
click to toggle source
# File lib/smuggle/exporter/base.rb, line 15 def attributes(*names) @attributes.concat names end
attributes?()
click to toggle source
# File lib/smuggle/exporter/base.rb, line 19 def attributes? @attributes.any? end
header()
click to toggle source
# File lib/smuggle/exporter/base.rb, line 31 def header return @attributes unless attribute_labels? @attributes.map do |attribute| @attribute_labels.fetch(attribute, attribute) end end
inherited(base)
click to toggle source
# File lib/smuggle/exporter/base.rb, line 10 def inherited(base) base.attributes = [] base.attribute_labels = {} end
Public Instance Methods
defined_attributes()
click to toggle source
# File lib/smuggle/exporter/base.rb, line 46 def defined_attributes return self.class.attributes if self.class.attributes? return attribute_names if __getobj__.respond_to?(:attribute_names) keys if __getobj__.respond_to?(:keys) end
to_csv()
click to toggle source
# File lib/smuggle/exporter/base.rb, line 40 def to_csv defined_attributes.map do |name| respond_to?(name) ? public_send(name) : __getobj__[name] end end