Sha256: ce9348044187c1e94e067add813437b1f66447b553869287e7fe383b775807dc

Contents?: true

Size: 1.58 KB

Versions: 123

Compression:

Stored size: 1.58 KB

Contents

module Sportradar
  module Api
    class Mma
      class Venue < Data
        attr_accessor :response, :id, :name, :address, :city, :state, :country, :zip, :capacity, :timezone
        @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

123 entries across 123 versions & 1 rubygems

Version Path
sportradar-api-0.13.9 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.8 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.7 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.6 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.5 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.4 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.3 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.2 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.1 lib/sportradar/api/mma/venue.rb
sportradar-api-0.13.0 lib/sportradar/api/mma/venue.rb
sportradar-api-0.12.3 lib/sportradar/api/mma/venue.rb
sportradar-api-0.12.2 lib/sportradar/api/mma/venue.rb
sportradar-api-0.12.1 lib/sportradar/api/mma/venue.rb
sportradar-api-0.12.0 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.69 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.68 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.67 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.66 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.65 lib/sportradar/api/mma/venue.rb
sportradar-api-0.11.64 lib/sportradar/api/mma/venue.rb