class FootballCli::Format::Base

Attributes

columns[R]
response[R]
rows[R]
title[R]

Public Class Methods

new(opts={}) click to toggle source
# File lib/football_cli/format/base.rb, line 6
def initialize(opts={})
  @response = opts[:response]
  @title = opts[:title]
  @columns = opts[:columns]
  @file_name = opts[:file_name]
  @qualification = opts[:qualification]

  @rows = []
end

Public Instance Methods

generate() click to toggle source
# File lib/football_cli/format/base.rb, line 16
def generate
  raise NotImplementedError, 'must implement generate() method in subclass'
end
goal_columns() click to toggle source
# File lib/football_cli/format/base.rb, line 28
def goal_columns
  %i(goalsHomeTeam goalsAwayTeam).freeze
end
output() click to toggle source
# File lib/football_cli/format/base.rb, line 20
def output
  if @file_name
    File.write(@file_name, generate)
  else
    puts generate
  end
end
qualification() click to toggle source
# File lib/football_cli/format/base.rb, line 32
def qualification
  Hash[@qualification.collect {|k, v| [ k, v.each_cons(2).map {|from, to| from..to }.max ] }] if @qualification
end