Sha256: 93cacc3b404c4d5ba5b9dd8218edbae1ff79bdcc1ff29ec13b3c98ca6a7bfeb6

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

module Sportradar
  module Api
    class Nfl::Hierarchy < Data
      attr_accessor :response, :id, :name, :alias, :divisions, :conferences

      def initialize(data)
        @response = data
        @id = data["id"]
        @name = data["name"]
        @alias = data["alias"]
        set_divisions
        set_conferences
      end

      private

      def set_divisions
        if response["division"]
          if response["division"].is_a?(Array)
            @divisions = response["division"].map {|division| Sportradar::Api::Nfl::Division.new division }
          elsif response["division"].is_a?(Hash)
            @divisions = [ Sportradar::Api::Nfl::Division.new(response["division"]) ]
          end
        end
      end

      def set_conferences
        if response["conference"]
          if response["conference"].is_a?(Array)
            @conferences = response["conference"].map {|conference| Sportradar::Api::Nfl::Conference.new conference }
          elsif response["conference"].is_a?(Hash)
            @conferences = [ Sportradar::Api::Nfl::Conference.new(response["conference"]) ]
          end
        end
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sportradar-api-0.1.23 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.22 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.21 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.19 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.18 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.17 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.16 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.15 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.14 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.13 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.12 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.11 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.10 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.8 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.7 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.6 lib/sportradar/api/nfl/hierarchy.rb
sportradar-api-0.1.5 lib/sportradar/api/nfl/hierarchy.rb