Class: Sportradar::Api::Baseball::Runner
- Defined in:
- lib/sportradar/api/baseball/runner.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#ending_base ⇒ Object
Returns the value of attribute ending_base.
-
#fielders ⇒ Object
Returns the value of attribute fielders.
-
#id ⇒ Object
Returns the value of attribute id.
-
#out ⇒ Object
Returns the value of attribute out.
-
#outcome ⇒ Object
Returns the value of attribute outcome.
-
#outcome_id ⇒ Object
Returns the value of attribute outcome_id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#starting_base ⇒ Object
Returns the value of attribute starting_base.
Instance Method Summary collapse
-
#initialize(data, **opts) ⇒ Runner
constructor
A new instance of Runner.
- #runner_outcome(code) ⇒ Object
- #runner_outcomes ⇒ Object
- #update(data, **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) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 11 12 |
# File 'lib/sportradar/api/baseball/runner.rb', line 7 def initialize(data, **opts) @response = data # @game = opts[:game] update(data) end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def description @description end |
#ending_base ⇒ Object
Returns the value of attribute ending_base.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def ending_base @ending_base end |
#fielders ⇒ Object
Returns the value of attribute fielders.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def fielders @fielders end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def id @id end |
#out ⇒ Object
Returns the value of attribute out.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def out @out end |
#outcome ⇒ Object
Returns the value of attribute outcome.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def outcome @outcome end |
#outcome_id ⇒ Object
Returns the value of attribute outcome_id.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def outcome_id @outcome_id end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def response @response end |
#starting_base ⇒ Object
Returns the value of attribute starting_base.
5 6 7 |
# File 'lib/sportradar/api/baseball/runner.rb', line 5 def starting_base @starting_base end |
Instance Method Details
#runner_outcome(code) ⇒ Object
28 29 30 |
# File 'lib/sportradar/api/baseball/runner.rb', line 28 def runner_outcome(code) runner_outcomes[code] end |
#runner_outcomes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sportradar/api/baseball/runner.rb', line 31 def runner_outcomes @runner_outcomes ||= { 'CK' => 'Checked', 'ERN' => 'Earned Run/RBI', 'eRN' => 'Earned Run/No RBI', 'URN' => 'Unearned Run/RBI', 'uRN' => 'Unearned Run/No RBI', 'PO' => 'Pickoff', 'POCS2' => 'Pickoff/Caught Stealing 2nd', 'POCS3' => 'Pickoff/Caught Stealing 3nd', 'POCS4' => 'Pickoff/Caught Stealing Home', 'AD1' => 'Advance 1st', 'AD2' => 'Advance 2nd', 'AD3' => 'Advance 3rd', 'SB2' => 'Stole 2nd', 'SB2E4E' => 'Stole 2nd, error to home (earned)', 'SB3' => 'Stole 3rd', 'SB3E4E' => 'Stole 3rd, error to home (earned)', 'SB4' => 'Stole Home', 'TO2' => 'Tag out 2nd', 'TO3' => 'Tag out 3rd', 'TO4' => 'Tag out Home', 'FO1' => 'Force out 1st', 'FO2' => 'Force out 2nd', 'FO3' => 'Force out 3rd', 'FO4' => 'Force out Home', 'CS2' => 'Caught Stealing 2nd', 'CS3' => 'Caught Stealing 3rd', 'CS4' => 'Caught Stealing Home', 'SB2E3' => 'Stole 2nd, error to 3rd', 'SB2E4' => 'Stole 2nd, error to Home', 'SB3E4' => 'Stole 3nd, error to Home', 'DI2' => 'Indifference to 2nd', 'DI3' => 'Indifference to 3rd', 'DO1' => 'Doubled off 1st', 'DO2' => 'Doubled off 2nd', 'DO3' => 'Doubled off 3rd', 'RI' => 'Runner Interference', 'OOA' => 'Out on Appeal', 'OBP' => 'Out of Base Path', 'HBB' => 'Hit by Batted Ball', } end |
#update(data, **opts) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sportradar/api/baseball/runner.rb', line 13 def update(data, **opts) @id = data["id"] @starting_base = data["starting_base"] @ending_base = data["ending_base"] @outcome_id = data["outcome_id"] @outcome = runner_outcome(@outcome_id) @out = data["out"] @last_name = data["last_name"] @first_name = data["first_name"] @preferred_name = data["preferred_name"] @jersey_number = data["jersey_number"] @description = data['description'] @fielders = data['fielders'].map { |hash| Fielder.new(hash) } if data['fielders'] end |