Sha256: 258dd1ed2c66f0b070be31c02ead7d4cc2d46f6bc2689aff17ce1d2bfc331c10
Contents?: true
Size: 1.1 KB
Versions: 170
Compression:
Stored size: 1.1 KB
Contents
module Sportradar module Api module Baseball class Inning < Data attr_accessor :response, :id, :game, :number, :sequence, :scoring def initialize(data, **opts) @response = data @api = opts[:api] @game = opts[:game] @id = data["id"] @number = data['number'] @sequence = data['sequence'] parse_scoring(data['scoring']) if data['scoring'] @half_innings_hash = {} update(data) end def update(data, **opts) # update scoring halfs = data['halfs'].each { |inning| inning['id'] = "#{data['id']}-#{inning['half']}" } create_data(@half_innings_hash, halfs, klass: HalfInning, api: @api, inning: self) end def parse_scoring(data) @scoring = data.each_with_object({}) { |(_, data), hash| hash[data['id']] = data['runs'].to_s } # from PBP end def half_innings @half_innings_hash.values end def events half_innings.flat_map(&:events) end end end end end
Version data entries
170 entries across 170 versions & 1 rubygems