Class: Skyhook::Game

Inherits:
Core show all
Defined in:
lib/skyhook/game.rb

Constant Summary

Constants inherited from Configuration

Configuration::BASE, Configuration::FORMATS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Core

api_reference, get_method, method_missing

Methods inherited from Configuration

configure

Constructor Details

#initialize(appid, steamid = nil) ⇒ Game

Returns a new instance of Game.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/skyhook/game.rb', line 6

def initialize( appid, steamid = nil )
  @appid = appid
  if steamid == nil
    # If steamid is not set a game should contain global data
    set_global_attributes
  else
    if steamid.is_a? Skyhook::User
      @user = steamid
    else
      @user = Skyhook::User.new steamid
    end

    set_user_attributes Skyhook::Core::ISteamUserStats.player_stats( appid, @user.steamid )
  end
end

Instance Attribute Details

#achievementsObject (readonly)

Returns the value of attribute achievements.



4
5
6
# File 'lib/skyhook/game.rb', line 4

def achievements
  @achievements
end

#appidObject (readonly)

Returns the value of attribute appid.



4
5
6
# File 'lib/skyhook/game.rb', line 4

def appid
  @appid
end

#game_nameObject (readonly)

Returns the value of attribute game_name.



4
5
6
# File 'lib/skyhook/game.rb', line 4

def game_name
  @game_name
end

#statsObject (readonly)

Returns the value of attribute stats.



4
5
6
# File 'lib/skyhook/game.rb', line 4

def stats
  @stats
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/skyhook/game.rb', line 4

def user
  @user
end

Instance Method Details

#set_global_attributesObject

Raises:

  • (NotImplementedError)


30
31
32
33
# File 'lib/skyhook/game.rb', line 30

def set_global_attributes
  #Will return a games global stats
  raise NotImplementedError
end

#set_user_attributes(response) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/skyhook/game.rb', line 22

def set_user_attributes( response )
  @game_name = response['gameName']

  @achievements = response['achievements']
  @stats = response['stats']
  @user.games= self
end