Sha256: 76ef6c9275a431d0dd19ff47e202ef62aa8070baeb621f3bb8e183a92e8348e8

Contents?: true

Size: 1.31 KB

Versions: 17

Compression:

Stored size: 1.31 KB

Contents

module Sportradar
  module Api
    class Images::Asset < Data
      attr_accessor :response, :id, :player_id, :created, :updated, :title, :description, :copyright, :links, :tags

      def initialize(data)
        @response = data
        @id = data["id"]
        @player_id = data["player_id"]
        @created = data["created"]
        @updated = data["updated"]
        @title = data["title"]
        @description = data["description"]
        @copyright = data["copyright"]

        set_links
        set_tags
      end

      private

      def set_links
        if response["links"] && response["links"]["link"]
          if response["links"]["link"].is_a?(Array)
            @links = response["links"]["link"].map {|x| Sportradar::Api::Images::Link.new x }
          elsif response["links"]["link"].is_a?(Hash)
            @links = [ Sportradar::Api::Images::Link.new(response["links"]["link"]) ]
          end
        end
      end

      def set_tags
        if response["tags"] && response["tags"]["tag"]
          if response["tags"]["tag"].is_a?(Array)
            @tags = response["tags"]["tag"].map {|x| Sportradar::Api::Images::Tag.new x }
          elsif response["tags"]["tag"].is_a?(Hash)
            @tags = [ Sportradar::Api::Images::Tag.new(response["tags"]["tag"]) ]
          end
        end
      end


    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sportradar-api-0.1.38 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.37 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.36 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.35 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.34 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.33 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.32 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.31 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.30 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.29 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.28 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.27 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.26 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.25 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.24 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.23 lib/sportradar/api/images/asset.rb
sportradar-api-0.1.22 lib/sportradar/api/images/asset.rb