Class: Sportradar::Api::Basketball::Play
- Defined in:
- lib/sportradar/api/basketball/play.rb,
lib/sportradar/api/basketball/plays/base.rb
Defined Under Namespace
Classes: Base
Instance Attribute Summary collapse
-
#clock ⇒ Object
Returns the value of attribute clock.
-
#description ⇒ Object
Returns the value of attribute description.
-
#event_type ⇒ Object
(also: #type)
Returns the value of attribute event_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
Returns the value of attribute location.
-
#on_court ⇒ Object
Returns the value of attribute on_court.
-
#player_id ⇒ Object
Returns the value of attribute player_id.
-
#possession ⇒ Object
Returns the value of attribute possession.
-
#quarter ⇒ Object
Returns the value of attribute quarter.
-
#response ⇒ Object
Returns the value of attribute response.
-
#score ⇒ Object
Returns the value of attribute score.
-
#statistics ⇒ Object
Returns the value of attribute statistics.
-
#team_id ⇒ Object
Returns the value of attribute team_id.
-
#updated ⇒ Object
Returns the value of attribute updated.
Class Method Summary collapse
-
.new(data, **opts) ⇒ Object
def self.new(data, **opts) existing = @all_hash[data] if existing existing.update(data, **opts) existing else klass = subclass(data) @all_hash[data] = klass.new(data, **opts) rescue (puts data; binding.pry) end end.
-
.subclass(event_type) ⇒ Object
def self.all @all_hash.values end.
- .subclasses ⇒ 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
Instance Attribute Details
#clock ⇒ Object
Returns the value of attribute clock.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def clock @clock end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def description @description end |
#event_type ⇒ Object Also known as: type
Returns the value of attribute event_type.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def event_type @event_type end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def location @location end |
#on_court ⇒ Object
Returns the value of attribute on_court.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def on_court @on_court end |
#player_id ⇒ Object
Returns the value of attribute player_id.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def player_id @player_id end |
#possession ⇒ Object
Returns the value of attribute possession.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def possession @possession end |
#quarter ⇒ Object
Returns the value of attribute quarter.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def quarter @quarter end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def response @response end |
#score ⇒ Object
Returns the value of attribute score.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def score @score end |
#statistics ⇒ Object
Returns the value of attribute statistics.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def statistics @statistics end |
#team_id ⇒ Object
Returns the value of attribute team_id.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def team_id @team_id end |
#updated ⇒ Object
Returns the value of attribute updated.
5 6 7 |
# File 'lib/sportradar/api/basketball/play.rb', line 5 def updated @updated end |
Class Method Details
.new(data, **opts) ⇒ Object
def self.new(data, **opts)
existing = @all_hash[data['id']]
if existing
existing.update(data, **opts)
existing
else
klass = subclass(data['event_type'])
@all_hash[data['id']] = klass.new(data, **opts) rescue (puts data['event_type']; binding.pry)
end
end
18 19 20 21 22 23 |
# File 'lib/sportradar/api/basketball/play.rb', line 18 def self.new(data, **opts) klass = subclass(data['event_type']) || Base klass.new(data, **opts) # rescue => e # binding.pry end |
.subclass(event_type) ⇒ Object
def self.all
@all_hash.values
end
28 29 30 |
# File 'lib/sportradar/api/basketball/play.rb', line 28 def self.subclass(event_type) subclasses[event_type] end |
.subclasses ⇒ 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 74 75 |
# File 'lib/sportradar/api/basketball/play.rb', line 31 def self.subclasses @subclasses ||= { "opentip" => OpenTip, "twopointmiss" => TwoPointMiss, "rebound" => Rebound, "threepointmiss" => ThreePointMiss, "twopointmade" => TwoPointMade, "threepointmade" => ThreePointMade, "turnover" => Turnover, "personalfoul" => PersonalFoul, "jumpball" => Jumpball, "deadball" => Deadball, "teamtimeout" => TeamTimeout, "shootingfoul" => ShootingFoul, "freethrowmade" => FreeThrowMade, "freethrowmiss" => FreeThrowMiss, "lineupchange" => LineupChange, "offensivefoul" => OffensiveFoul, "endperiod" => EndPeriod, "openinbound" => OpenInbound, "officialtimeout" => OfficialTimeout, "kickball" => Kickball, "tvtimeout" => TvTimeout, "clearpathfoul" => ClearPathFoul, "technicalfoul" => TechnicalFoul, "minortechnicalfoul" => TechnicalFoul, "review" => Review, "defensivethreeseconds" => DefensiveThreeSeconds, "flagrantone" => FlagrantOne, "flagranttwo" => FlagrantTwo, "delay" => Delay, "ejection" => Ejection, "defaultviolation" => DefaultViolation, "jumpballviolation" => JumpballViolation, "defensivegoaltending" => DefensiveGoalTending, "doublelane" => DoubleLane, "lane" => Lane, "possession" => Possession, "stoppage" => Stoppage, # abstract types, used for lookup purposes "foul" => Foul, "shotmade" => ShotMade, "shotmiss" => ShotMiss, }.freeze end |