Sha256: 4ead61b3fef0ba32cc9f5a36003d841e7abb436ff388bb7e4778b3a9c9a1bdf5

Contents?: true

Size: 1.95 KB

Versions: 4

Compression:

Stored size: 1.95 KB

Contents

require_relative "./collection/player_collection.rb"
require_relative "./collection/team_collection.rb"
require_relative "./collection/leaderboard_collection.rb"
require_relative "./collection/action_collection.rb"
require_relative "./collection/metric_collection.rb"

require_relative "../game.rb"

module PlaylyfeClient
  module V2
    #Game is 1:1 to connection, so only one instance per connection
    #finding is done by credentials
    class Game < PlaylyfeClient::Game

      attr_reader :game_hash, :description, :id, :type, :timezone, :created_at
      attr_accessor :ignore_rate_limit_errors

      def self.find_by_connection(conn)
        PlaylyfeClient::V2::Game.new(conn)
      end  
         
      def players
        @players ||= PlaylyfeClient::V2::PlayerCollection.new(self)
      end

      def teams 
        @teams ||= PlaylyfeClient::V2::TeamCollection.new(self)
      end  

      def metrics
        @metrics ||= PlaylyfeClient::V2::MetricCollection.new(self)
      end 
     
      def actions
        @actions ||= PlaylyfeClient::V2::ActionCollection.new(self)
      end

      def available_actions
        actions
      end  

      def leaderboards
        @leaderboards ||= PlaylyfeClient::V2::LeaderboardCollection.new(self)
      end

      def image_data(style=:original)
        data=connection.get_game_image_data
        puts(data)
      end  

      private

        def initialize(conn)    
          super(conn)
          @game_hash=connection.get_game_hash
          #name is not name of Game but rather connection   @name= game_hash["name"]
          @description=game_hash["description"]
          @id=game_hash["id"]
          @image=game_hash["image"]
          @title=game_hash["title"]
          @type=game_hash["type"]
          @timezone=game_hash["timezone"] #TODO converion to TZInfo::Timezone ? http://www.rubydoc.info/gems/tzinfo/frames
          @created_at=Time.parse(game_hash["created"])
        end  

     

    end
  end  
end    

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playlyfe_client-1.0.6 lib/playlyfe_client/v2/game.rb
playlyfe_client-1.0.5 lib/playlyfe_client/v2/game.rb
playlyfe_client-1.0.4 lib/playlyfe_client/v2/game.rb
playlyfe_client-1.0.2 lib/playlyfe_client/v2/game.rb