Sha256: e6eba0186193153f651fe8fc0ab69d26f7db600eea3698c6c58222a240e2149d

Contents?: true

Size: 929 Bytes

Versions: 20

Compression:

Stored size: 929 Bytes

Contents

module Sportradar
  module Api
    class Soccer::Schedule < Data
      attr_accessor :response, :matches

      def initialize(data)
        @response = data
        set_matches
      end

      def league(league_name)
        matches.select{ |match| match.tournament_group.name.parameterize == league_name.parameterize}
      end

      def available_leagues
        matches.map {|match| match.tournament_group.name}.uniq
      end

      private
      def set_matches
        if response["schedule"]["matches"]["match"]
          if response["schedule"]["matches"]["match"].is_a?(Array)
            @matches = response["schedule"]["matches"]["match"].map {|x| Sportradar::Api::Soccer::Match.new x }
          elsif response["schedule"]["matches"]["match"].is_a?(Hash)
            @matches = [ Sportradar::Api::Soccer::Match.new(response["schedule"]["matches"]["match"]) ]
          end
        end
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
sportradar-api-0.1.38 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.37 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.36 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.35 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.34 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.33 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.32 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.31 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.30 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.29 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.28 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.27 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.26 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.25 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.24 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.23 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.22 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.21 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.19 lib/sportradar/api/soccer/schedule.rb
sportradar-api-0.1.18 lib/sportradar/api/soccer/schedule.rb