Sha256: 8bbed2f62d2a3641cf16e34f9719575581f8ab1a31ab50d65db6a85f7b6c487c

Contents?: true

Size: 934 Bytes

Versions: 32

Compression:

Stored size: 934 Bytes

Contents

module Sportradar
  module Api
    class Soccer::Tournament < Data
      attr_accessor :response, :id, :name, :season_start, :season_end, :season, :type, :reference_id, :coverage, :teams

      def initialize(data)
        @response = data
        @id = data["id"]
        @name = data["name"]
        @season_start = data["season_start"]
        @season_end = data["season_end"]
        @season = data["season"]
        @reference_id = data["reference_id"]
        @coverage = OpenStruct.new data["coverage"] if data["coverage"]
        set_teams

      end

      private

      def set_teams
        if response["team"]
          if response["team"].is_a?(Array)
            @teams = response["team"].map {|team| Sportradar::Api::Soccer::Team.new team }
          elsif response["team"].is_a?(Hash)
            @teams = [ Sportradar::Api::Soccer::Team.new(response["team"]) ]
          end
        end
      end

    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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