Class: Quandl::Format::Dataset::Dump
- Inherits:
-
Object
- Object
- Quandl::Format::Dataset::Dump
- Defined in:
- lib/quandl/format/dataset/dump.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Class Method Summary collapse
Instance Method Summary collapse
- #column_names ⇒ Object
- #data ⇒ Object
-
#initialize(r) ⇒ Dump
constructor
A new instance of Dump.
- #meta_attributes ⇒ Object
- #to_qdf ⇒ Object
Constructor Details
#initialize(r) ⇒ Dump
Returns a new instance of Dump.
17 18 19 |
# File 'lib/quandl/format/dataset/dump.rb', line 17 def initialize(r) self.record = r end |
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
15 16 17 |
# File 'lib/quandl/format/dataset/dump.rb', line 15 def record @record end |
Class Method Details
.collection(*args) ⇒ Object
5 6 7 |
# File 'lib/quandl/format/dataset/dump.rb', line 5 def collection(*args) Array(args).flatten.collect{|r| record(r) }.join("\n") end |
.record(record) ⇒ Object
9 10 11 |
# File 'lib/quandl/format/dataset/dump.rb', line 9 def record(record) self.new(record).to_qdf end |
Instance Method Details
#column_names ⇒ Object
40 41 42 |
# File 'lib/quandl/format/dataset/dump.rb', line 40 def column_names record.column_names.to_csv if record.column_names.present? end |
#data ⇒ Object
33 34 35 36 37 38 |
# File 'lib/quandl/format/dataset/dump.rb', line 33 def data data = record.data data = data.collect(&:to_csv).join if data.is_a?(Array) && data.first.respond_to?(:to_csv) data = data.to_csv if data.respond_to?(:to_csv) data end |
#meta_attributes ⇒ Object
29 30 31 |
# File 'lib/quandl/format/dataset/dump.rb', line 29 def record..stringify_keys.to_yaml[4..-1] + "-\n" end |
#to_qdf ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/quandl/format/dataset/dump.rb', line 21 def to_qdf [ , column_names, data ].compact.join end |