Class: Sportradar::Api::Baseball::Outcome

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/baseball/outcome.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) ⇒ Outcome

Returns a new instance of Outcome.



7
8
9
10
11
12
13
14
15
16
# File 'lib/sportradar/api/baseball/outcome.rb', line 7

def initialize(data, **opts)
  @response = data
  @api      = opts[:api]
  @game     = opts[:game]
  
  @scores = {}
  @id = data['id']
  
  update(data, **opts)
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def count
  @count
end

#current_inningObject

Returns the value of attribute current_inning.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def current_inning
  @current_inning
end

#current_inning_halfObject

Returns the value of attribute current_inning_half.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def current_inning_half
  @current_inning_half
end

#hitterObject

Returns the value of attribute hitter.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def hitter
  @hitter
end

#pitcherObject

Returns the value of attribute pitcher.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def pitcher
  @pitcher
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def response
  @response
end

#runnersObject

Returns the value of attribute runners.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def runners
  @runners
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/sportradar/api/baseball/outcome.rb', line 5

def type
  @type
end

Instance Method Details

#update(data, source: nil, **opts) ⇒ Object



18
19
20
# File 'lib/sportradar/api/baseball/outcome.rb', line 18

def update(data, source: nil, **opts)
  update_from_outcome(data['outcome']) if data['outcome']
end

#update_from_outcome(data) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/sportradar/api/baseball/outcome.rb', line 22

def update_from_outcome(data)
  @type                 = data['type']                 if data['type']
  @current_inning       = data['current_inning']       if data['current_inning']
  @current_inning_half  = data['current_inning_half']  if data['current_inning_half']
  @count                = data['count']                if data['count']
  @hitter               = data['hitter']               if data['hitter']
  @pitcher              = data['pitcher']              if data['pitcher']
  @runners              = data['runners']              if data['runners']
end