Sha256: 264ab0ebaf896e37597ade1230e0e290cf71425fa3f52e99845777e1fbcefb4d

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

module Sportradar
  module Api
    module Basketball
      class Nba
        class Series < Basketball::Season
          attr_accessor :response, :id, :status, :title, :round, :start_date
          alias :name :title

          def initialize(data, **opts)
            @response = data
            @api      = opts[:api]

            @id         = data['id']
            @games_hash = {}
            @participants_hash = {}

            update(data, **opts)
          end

          def update(data, **opts)
            @title      = data['title']       if data['title']
            @round      = data['round']       if data['round']
            @status     = data['status']      if data['status']
            @start_date = data['start_date']  if data['start_date']


            update_games(data['games'])                 if data['games']
            update_participantss(data['participantss']) if data['participantss']
          end

          def games
            @games_hash.values
          end

          def update_games(data)
            create_data(@games_hash, data, klass: Game, api: @api, series: self)
          end

          def participants
            @participants_hash.values
          end

          def update_participants(data)
            create_data(@participants_hash, data, klass: Team, api: @api, series: self)
          end

        end
      end
    end
  end
end

__END__

sd = sr.daily_schedule;
sr = Sportradar::Api::Basketball::Nba.new
ss = sr.standings;
ss = sr.schedule;
ss = sr.schedule(2015, 'pst)');

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sportradar-api-0.10.7 lib/sportradar/api/basketball/nba/series.rb