Sha256: 73fad9cd1d84cb5aa968b305fafdf7875b8080db8633599fb6800e710f2d5834

Contents?: true

Size: 1.06 KB

Versions: 211

Compression:

Stored size: 1.06 KB

Contents

module Sportradar
  module Api
    class Mma
      class Schedule < Data
        attr_accessor :response, :id, :name, :scheduled, :venue

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

          @generated   = response['generated']
          @events_hash = {}
          update(data)
        end

        def events
          @events_hash ||= update_events(response)
          @events_hash.values
        end

        def update(data)
          update_events(data)

          self
        end

        def update_events(data)
          create_data(@events_hash, response.dig('events', 'event'), klass: Event, api: api, schedule: self)
        end
        def api
          @api ||= Sportradar::Api::Mma.new
        end


        KEYS_SCHED = ["id", "name", "scheduled", "venue", "league", "fights"]

      end
    end
  end
end

__END__

m = Sportradar::Api::Mma.new
sc = m.schedule;
se = m.events;
sc.events.size
e = sc.events.last;
e.venue.events.size

Sportradar::Api::Mma::Schedule.new({}, api: m)
Sportradar::Api::Mma::Schedule.new

Version data entries

211 entries across 211 versions & 1 rubygems

Version Path
sportradar-api-0.19.6 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.5 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.4 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.3 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.2 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.1 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.19.0 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.18.1 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.18.0 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.6 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.5 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.5.pre lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.4 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.3 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.2 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.1 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.0 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.17.0.pre lib/sportradar/api/mma/schedule.rb
sportradar-api-0.16.1 lib/sportradar/api/mma/schedule.rb
sportradar-api-0.16.0 lib/sportradar/api/mma/schedule.rb