Class: GameAchievement

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/community/game_achievement.rb

Overview

The GameAchievement class represents a specific achievement for a single game and for a single user

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(steam_id64, app_id, achievement_data) ⇒ GameAchievement

Creates the achievement with the given name for the given user and game and achievement data



14
15
16
17
18
19
20
21
22
23
# File 'lib/steam/community/game_achievement.rb', line 14

def initialize(steam_id64, app_id, achievement_data)
  @app_id     = app_id
  @name       = achievement_data.elements['name'].text
  @steam_id64 = steam_id64
  @unlocked   = (achievement_data.attributes['closed'].to_i == 1)

  if @unlocked && !achievement_data.elements['unlockTimestamp'].nil?
    @timestamp  = Time.at(achievement_data.elements['unlockTimestamp'].text.to_i)
  end
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



10
11
12
# File 'lib/steam/community/game_achievement.rb', line 10

def app_id
  @app_id
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/steam/community/game_achievement.rb', line 10

def name
  @name
end

#steam_id64Object (readonly)

Returns the value of attribute steam_id64.



10
11
12
# File 'lib/steam/community/game_achievement.rb', line 10

def steam_id64
  @steam_id64
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



10
11
12
# File 'lib/steam/community/game_achievement.rb', line 10

def timestamp
  @timestamp
end

Instance Method Details

#unlocked?Boolean

Returns whether this achievement has been unlocked by its owner

Returns:

  • (Boolean)


26
27
28
# File 'lib/steam/community/game_achievement.rb', line 26

def unlocked?
  @unlocked
end