Sha256: 9f6e1f1529dd834ab8258fda642ffead15177c4670987b13ba8509b3b48af1c4

Contents?: true

Size: 926 Bytes

Versions: 2

Compression:

Stored size: 926 Bytes

Contents

module Sportradar
  module Api
    module Football
      class StatPack < Data
        attr_accessor :response, :player, :name, :id, :position, :yards

        def initialize(data)
          @response = data
          set_stats
          # @player = Sportradar::Api::Nfl::Player.new(response) if response['name'] # this isn't used yet, and we need to determine a better solution
        end

        def players
          @players ||= set_players
        end

        private

        def set_stats
          raise NotImplementedError, "Please implement `#{self.class}#set_stats`"
        end

        def set_players
          if response["player"]
            if response["player"].is_a? Hash
              @players = [ self.class.new(response["player"]) ]
            else
              @players = response["player"].map{ |hash| self.class.new(hash) }
            end
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sportradar-api-0.1.33 lib/sportradar/api/football/stat_pack.rb
sportradar-api-0.1.32 lib/sportradar/api/football/stat_pack.rb