Class: Sportradar::Api::Soccer::Scoring
- Defined in:
- lib/sportradar/api/soccer/scoring.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#away ⇒ Object
Returns the value of attribute away.
-
#home ⇒ Object
Returns the value of attribute home.
-
#id ⇒ Object
Returns the value of attribute id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#scores ⇒ Object
Returns the value of attribute scores.
Instance Method Summary collapse
- #goals(team_id) ⇒ Object
-
#initialize(data, **opts) ⇒ Scoring
constructor
A new instance of Scoring.
- #update(data, source: nil, **opts) ⇒ Object
Methods inherited from Data
#all_attributes, #attributes, #create_data, #parse_into_array, #parse_into_array_with_options, #parse_out_hashes, #structure_links, #update_data
Constructor Details
#initialize(data, **opts) ⇒ Scoring
Returns a new instance of Scoring.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 7 def initialize(data, **opts) @api = opts[:api] @match = opts[:match] @scores = {} @id = data['id'] update(data, **opts) end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def api @api end |
#away ⇒ Object
Returns the value of attribute away.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def away @away end |
#home ⇒ Object
Returns the value of attribute home.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def home @home end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def id @id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def response @response end |
#scores ⇒ Object
Returns the value of attribute scores.
5 6 7 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 5 def scores @scores end |
Instance Method Details
#goals(team_id) ⇒ Object
43 44 45 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 43 def goals(team_id) @score[team_id].to_i end |
#update(data, source: nil, **opts) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sportradar/api/soccer/scoring.rb', line 17 def update(data, source: nil, **opts) # new_scores = case source # when :box # parse_from_box(data) # when :timeline # parse_from_timeline(data) # when :summary # parse_from_box(data) # else # if data['period'] || data['half'] # parse_from_timeline(data) # elsif data['team'] # parse_from_box(data) # else # schedule requests # {} # end # end new_scores = parse_from_timeline(data) # parse data structure # handle data from team (all periods) # handle data from period (both teams) # handle data from match? @scores.each { |k, v| v.merge!(new_scores.delete(k) || {} ) } new_scores.each { |k, v| @scores.merge!(k => v) } end |