Sha256: 430ee690e2f35945fe72f20ab47cb651b8776c737b8541679707a66b4ee8d70a

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

module Sportradar
  module Api
    class Content::ArticleList < Data
      attr_accessor :response, :provider, :sport, :start_time, :end_time, :articles

      def initialize(data)
        @response = data
        @sport = data["sport"]
        @provider = data["provider"]
        @start_time = Time.parse(data["start_time"]) if data["start_time"]
        @end_time = Time.parse(data["end_time"]) if data["end_time"]
        set_articles
      end

      private
      def set_articles
        if response["item"]
          if response["item"].is_a?(Array)
            @articles = response["item"].map {|x| Sportradar::Api::Content::Article.new x }
          elsif response["item"].is_a?(Hash)
            @articles = [ Sportradar::Api::Content::Article.new(response["item"]) ]
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sportradar-api-0.1.38 lib/sportradar/api/content/article_list.rb
sportradar-api-0.1.37 lib/sportradar/api/content/article_list.rb