Class: Sportradar::Api::Mma::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/mma/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#drawObject

Returns the value of attribute draw.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def draw
  @draw
end

#endpositionObject

Returns the value of attribute endposition.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def endposition
  @endposition
end

#endstrikeObject

Returns the value of attribute endstrike.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def endstrike
  @endstrike
end

#endtargetObject

Returns the value of attribute endtarget.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def endtarget
  @endtarget
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def id
  @id
end

#outcomeObject

Returns the value of attribute outcome.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def outcome
  @outcome
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def response
  @response
end

#roundObject

Returns the value of attribute round.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def round
  @round
end

#submissionObject

Returns the value of attribute submission.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def submission
  @submission
end

#timeObject

Returns the value of attribute time.



5
6
7
# File 'lib/sportradar/api/mma/result.rb', line 5

def time
  @time
end

#winnerObject

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

#apiObject



45
46
47
# File 'lib/sportradar/api/mma/result.rb', line 45

def api
  @api ||= Sportradar::Api::Mma.new
end

#scoresObject



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