lib/sportradar/api/basketball/play.rb in sportradar-api-0.9.59 vs lib/sportradar/api/basketball/play.rb in sportradar-api-0.10.0

- old
+ new

@@ -15,27 +15,33 @@ # @all_hash[data['id']] = klass.new(data, **opts) rescue (puts data['event_type']; binding.pry) # end # end def self.new(data, **opts) klass = subclass(data['event_type']) - klass.new(data, **opts) rescue nil + klass.new(data, **opts) + # rescue => e + # binding.pry end # def self.all # @all_hash.values # end def self.subclass(event_type) - { + subclasses[event_type] + end + 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, @@ -51,15 +57,19 @@ "defensivethreeseconds" => DefensiveThreeSeconds, "flagrantone" => FlagrantOne, "flagranttwo" => FlagrantTwo, "delay" => Delay, "ejection" => Ejection, - }[event_type] + # abstract types, used for lookup purposes + "foul" => Foul, + "shotmade" => ShotMade, + "shotmiss" => ShotMiss, + }.freeze end - SHOT_TYPES = %w[driving pullup step back fadeaway putback floating finger roll turnaround reverse alley-oop] + # SHOT_TYPES = %w[driving pullup step back fadeaway putback floating finger roll turnaround reverse alley-oop] - PLAY_TYPES = %w[clearpathfoul defensivethreeseconds delay ejection endperiod flagrantone flagranttwo freethrowmade freethrowmiss jumpball kickball offensivefoul officialtimeout openinbound opentip personalfoul possession rebound review shootingfoul teamtimeout technicalfoul threepointmade threepointmiss turnover tvtimeout twopointmade twopointmiss warning] + # PLAY_TYPES = %w[clearpathfoul defensivethreeseconds delay ejection endperiod flagrantone flagranttwo freethrowmade freethrowmiss jumpball kickball offensivefoul officialtimeout openinbound opentip personalfoul possession rebound review shootingfoul teamtimeout technicalfoul threepointmade threepointmiss turnover tvtimeout twopointmade twopointmiss warning] end end end end