Class: FootballCli::Format::Base
- Inherits:
-
Object
- Object
- FootballCli::Format::Base
- Defined in:
- lib/football_cli/format/base.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #generate ⇒ Object
- #goal_columns ⇒ Object
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #output ⇒ Object
- #qualification ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
4 5 6 |
# File 'lib/football_cli/format/base.rb', line 4 def columns @columns end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/football_cli/format/base.rb', line 4 def response @response end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
4 5 6 |
# File 'lib/football_cli/format/base.rb', line 4 def rows @rows end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/football_cli/format/base.rb', line 4 def title @title end |
Instance Method Details
#generate ⇒ Object
16 17 18 |
# File 'lib/football_cli/format/base.rb', line 16 def generate raise NotImplementedError, 'must implement generate() method in subclass' end |
#goal_columns ⇒ Object
28 29 30 |
# File 'lib/football_cli/format/base.rb', line 28 def goal_columns %i(goalsHomeTeam goalsAwayTeam).freeze end |
#output ⇒ Object
20 21 22 23 24 25 26 |
# 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 ⇒ Object
32 33 34 |
# 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 |