Class: Rorschart::RorschartData
- Inherits:
-
Object
- Object
- Rorschart::RorschartData
- Defined in:
- lib/rorschart/data/rorschart_data.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#cols ⇒ Object
Returns the value of attribute cols.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(raw_data) ⇒ RorschartData
constructor
A new instance of RorschartData.
- #sort_by_date! ⇒ Object
Constructor Details
#initialize(raw_data) ⇒ RorschartData
Returns a new instance of RorschartData.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rorschart/data/rorschart_data.rb', line 7 def initialize(raw_data) data = convert_objects_to_array_of_hash(raw_data) case data when Array case data.first when Array cols = columns_from_array_row(data.first) when Hash cols = columns_from_hash_row(data) data = data.map{|row| row.values} end when Hash cols = columns_from_array_row(data.first) end @rows = data.to_a @cols = cols end |
Instance Attribute Details
#cols ⇒ Object
Returns the value of attribute cols.
5 6 7 |
# File 'lib/rorschart/data/rorschart_data.rb', line 5 def cols @cols end |
#rows ⇒ Object
Returns the value of attribute rows.
5 6 7 |
# File 'lib/rorschart/data/rorschart_data.rb', line 5 def rows @rows end |
Instance Method Details
#sort_by_date! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rorschart/data/rorschart_data.rb', line 28 def sort_by_date! return if @cols.blank? if ['datetime', 'date'].include? @cols.first[:type] @rows = @rows.sort_by{ |c| c.first } end end |