Class: Sportradar::Api::Basketball::Play

Inherits:
Data
  • Object
show all
Defined in:
lib/sportradar/api/basketball/play.rb,
lib/sportradar/api/basketball/plays/base.rb

Defined Under Namespace

Classes: Base

Instance Attribute Summary collapse

Class 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

Instance Attribute Details

#clockObject

Returns the value of attribute clock.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def clock
  @clock
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def description
  @description
end

#event_typeObject 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

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def id
  @id
end

#locationObject

Returns the value of attribute location.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def location
  @location
end

#on_courtObject

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_idObject

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

#possessionObject

Returns the value of attribute possession.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def possession
  @possession
end

#quarterObject

Returns the value of attribute quarter.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def quarter
  @quarter
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def response
  @response
end

#scoreObject

Returns the value of attribute score.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def score
  @score
end

#statisticsObject

Returns the value of attribute statistics.



5
6
7
# File 'lib/sportradar/api/basketball/play.rb', line 5

def statistics
  @statistics
end

#team_idObject

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

#updatedObject

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

.subclassesObject



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