Class: Sportradar::Api::Mma::Result
- Defined in:
- lib/sportradar/api/mma/result.rb
Instance Attribute Summary collapse
-
#draw ⇒ Object
Returns the value of attribute draw.
-
#endposition ⇒ Object
Returns the value of attribute endposition.
-
#endstrike ⇒ Object
Returns the value of attribute endstrike.
-
#endtarget ⇒ Object
Returns the value of attribute endtarget.
-
#id ⇒ Object
Returns the value of attribute id.
-
#outcome ⇒ Object
Returns the value of attribute outcome.
-
#response ⇒ Object
Returns the value of attribute response.
-
#round ⇒ Object
Returns the value of attribute round.
-
#submission ⇒ Object
Returns the value of attribute submission.
-
#time ⇒ Object
Returns the value of attribute time.
-
#winner ⇒ Object
Returns the value of attribute winner.
Instance Method Summary collapse
- #add_score(score) ⇒ Object
- #api ⇒ Object
-
#initialize(data, **opts) ⇒ Result
constructor
A new instance of Result.
- #scores ⇒ Object
- #update(data, **opts) ⇒ Object
- #update_scores(data) ⇒ 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) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sportradar/api/mma/result.rb', line 7 def initialize(data, **opts) @response = data @api = opts[:api] @fight = opts[:fight] @scores_hash = {} update(data) end |
Instance Attribute Details
#draw ⇒ Object
Returns the value of attribute draw.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def draw @draw end |
#endposition ⇒ Object
Returns the value of attribute endposition.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def endposition @endposition end |
#endstrike ⇒ Object
Returns the value of attribute endstrike.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def endstrike @endstrike end |
#endtarget ⇒ Object
Returns the value of attribute endtarget.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def endtarget @endtarget end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def id @id end |
#outcome ⇒ Object
Returns the value of attribute outcome.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def outcome @outcome end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def response @response end |
#round ⇒ Object
Returns the value of attribute round.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def round @round end |
#submission ⇒ Object
Returns the value of attribute submission.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def submission @submission end |
#time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def time @time end |
#winner ⇒ Object
Returns the value of attribute winner.
5 6 7 |
# File 'lib/sportradar/api/mma/result.rb', line 5 def winner @winner end |
Instance Method Details
#add_score(score) ⇒ Object
20 21 22 |
# File 'lib/sportradar/api/mma/result.rb', line 20 def add_score(score) @scores_hash[score.id] = score if score end |
#api ⇒ Object
45 46 47 |
# File 'lib/sportradar/api/mma/result.rb', line 45 def api @api ||= Sportradar::Api::Mma.new end |
#scores ⇒ Object
17 18 19 |
# File 'lib/sportradar/api/mma/result.rb', line 17 def scores @scores_hash.values end |
#update(data, **opts) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sportradar/api/mma/result.rb', line 25 def update(data, **opts) @round = data['round'] if data['round'] # "3", @time = data['time'] if data['time'] # "05:00", @outcome = data['method'] if data['method'] # "Decision - Split", @submission = data['submission'] if data['submission'] # "", @endstrike = data['endstrike'] if data['endstrike'] # "", @endtarget = data['endtarget'] if data['endtarget'] # "", @endposition = data['endposition'] if data['endposition'] # "", @winner = data['winner'] if data['winner'] # "3043fe6a-1f8b-4aa7-85fe-8f8859740cc4", @draw = data['draw'] if data['draw'] # "false", update_scores(data) self end |
#update_scores(data) ⇒ Object
39 40 41 42 43 |
# File 'lib/sportradar/api/mma/result.rb', line 39 def update_scores(data) return if String === data['scores'] create_data(@scores_hash, data.dig('scores', 'judge'), klass: Score, api: api, result: self) # @judges = Judge.new(data['judges'], fight: self, api: api) if data['judges'] end |