Class: WorldCup::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/world_cup/results.rb

Constant Summary collapse

SFG_ENDPOINT =
'http://worldcup.sfg.io/matches'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Results

Returns a new instance of Results.



14
15
16
17
18
19
20
# File 'lib/world_cup/results.rb', line 14

def initialize(opts={})
  @opts = opts
  @raw_response = nil
  @response = nil
  @rows = nil
  @table = nil
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



12
13
14
# File 'lib/world_cup/results.rb', line 12

def raw_response
  @raw_response
end

#responseObject (readonly)

Returns the value of attribute response.



12
13
14
# File 'lib/world_cup/results.rb', line 12

def response
  @response
end

#tableObject (readonly)

Returns the value of attribute table.



12
13
14
# File 'lib/world_cup/results.rb', line 12

def table
  @table
end

Instance Method Details

#renderObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/world_cup/results.rb', line 22

def render
  unless retrieve
    puts "Sorry, #{SFG_ENDPOINT} could not be reached. Please check your internet connection and try again."
    return
  end
  unless convert
    puts "Sorry, the response at #{SFG_ENDPOINT} could not be interpreted. Please try again."
    return
  end
  select_matches
  compose_table
  puts @table
end