Class: IActionable::Objects::ProfileSummary

Inherits:
IActionableObject show all
Defined in:
lib/iactionable/objects/profile_summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from IActionableObject

timestamp_regexp, timestamp_to_seconds

Constructor Details

#initialize(key_values = {}) ⇒ ProfileSummary

Returns a new instance of ProfileSummary.



10
11
12
13
14
15
16
# File 'lib/iactionable/objects/profile_summary.rb', line 10

def initialize(key_values={})
  @identifiers = extract_many_as(key_values, "Identifiers", IActionable::Objects::Identifier)
  @points = extract_many_as(key_values, "Points", IActionable::Objects::ProfilePoints)
  @recent_achievements = extract_many_as(key_values, "RecentAchievements", IActionable::Objects::Achievement)
  
  super(key_values)
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



4
5
6
# File 'lib/iactionable/objects/profile_summary.rb', line 4

def display_name
  @display_name
end

#identifiersObject

Returns the value of attribute identifiers.



5
6
7
# File 'lib/iactionable/objects/profile_summary.rb', line 5

def identifiers
  @identifiers
end

#pointsObject

Returns the value of attribute points.



6
7
8
# File 'lib/iactionable/objects/profile_summary.rb', line 6

def points
  @points
end

#rankObject

not always present



8
9
10
# File 'lib/iactionable/objects/profile_summary.rb', line 8

def rank
  @rank
end

#recent_achievementsObject

not always present



7
8
9
# File 'lib/iactionable/objects/profile_summary.rb', line 7

def recent_achievements
  @recent_achievements
end

Instance Method Details

#to_hashObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/iactionable/objects/profile_summary.rb', line 18

def to_hash
  hash = {
    "DisplayName" => @display_name,
    "Identifiers" => @identifiers.map{|identifier| identifier.to_hash}
  }
  unless @points.nil?
    hash["Points"] = @points.kind_of?(Array) ? @points.map{|point| point.to_hash} : @points
  end
  hash["RecentAchievements"] = @recent_achievements.map{|recent_achievement| recent_achievement.to_hash} unless @recent_achievements.empty?
  hash["Rank"] = @rank unless @rank.nil?
  hash
end