Sha256: 7a2a55f68d7046b535ab7eef933907298a1db928aac002589b2daf1320ea3084

Contents?: true

Size: 1.56 KB

Versions: 88

Compression:

Stored size: 1.56 KB

Contents

module Sportradar
  module Api
    class Mma
      class Venue < Data
        attr_accessor :response, :id, :event, :name, :country_code, :country, :state, :city
        @all_hash = {}
        def self.new(data, **opts)
          existing = @all_hash[data['name']]
          if existing
            existing.update(data)
            existing.add_event(opts[:event])
            existing
          else
            @all_hash[data['name']] = super
          end
        end
        def self.all
          @all_hash.values
        end

        def initialize(data, **opts)
          @response = data
          @api      = opts[:api]
          @event    = opts[:event]
          @events_hash = {}

          @id       = data['id']

          update(data)
        end

        def events
          @events_hash.values
        end
        def add_event(event)
          @events_hash[event.id] = event if event
        end

        def update(data, **opts)
          @name         = data['name']
          @country_code = data['country_code']
          @country      = data['country']
          @state        = data['state']
          @city         = data['city']

          @id         = @name + ', ' + @city

          self
        end

        def add_event(event)
          @events << event if event
        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;
sc.events.size
e = sc.events.last;
e.venue.events.size

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
sportradar-api-0.10.35 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.34 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.33 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.32 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.31 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.30 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.29 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.28 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.27 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.26 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.25 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.24 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.23 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.22 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.21 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.20 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.19 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.18 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.17 lib/sportradar/api/mma/venue.rb
sportradar-api-0.10.16 lib/sportradar/api/mma/venue.rb