Class: FootballCli::Format::Csv

Inherits:
Base
  • Object
show all
Defined in:
lib/football_cli/format/csv.rb

Instance Attribute Summary

Attributes inherited from Base

#columns, #response, #rows, #title

Instance Method Summary collapse

Methods inherited from Base

#goal_columns, #initialize, #output, #qualification

Constructor Details

This class inherits a constructor from FootballCli::Format::Base

Instance Method Details

#generateObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/football_cli/format/csv.rb', line 7

def generate
  @generate ||= CSV.generate do |csv|
    csv << columns

    response.each do |data|
      csv << columns.collect {|c|
        if goal_columns.include?(c) && data[:result]
          data[:result][c]
        else
          data[c]
        end
      }
    end
  end
end