lib/gattica/data_set.rb in cannikin-gattica-0.2.0 vs lib/gattica/data_set.rb in cannikin-gattica-0.3.1

- old
+ new

@@ -30,24 +30,36 @@ case format when :long output = '"id","updated","title",' end - output += @points.first.dimensions.collect do |dimension| - "\"#{dimension.key.to_s}\"" - end.join(',') - output += ',' - output += @points.first.metrics.collect do |metric| - "\"#{metric.key.to_s}\"" - end.join(',') - output += "\n" + unless @points.empty? # if there was at least one result + output += @points.first.dimensions.collect do |dimension| + "\"#{dimension.key.to_s}\"" + end.join(',') + output += ',' + output += @points.first.metrics.collect do |metric| + "\"#{metric.key.to_s}\"" + end.join(',') + output += "\n" + end # get the data from each point @points.each do |point| output += point.to_csv(format) + "\n" end return output + end + + + def to_yaml + { 'total_results' => @total_results, + 'start_index' => @start_index, + 'items_per_page' => @items_per_page, + 'start_date' => @start_date, + 'end_date' => @end_date, + 'points' => @points}.to_yaml end end end \ No newline at end of file