Class: Badgeville::Activity
- Inherits:
-
Object
- Object
- Badgeville::Activity
- Defined in:
- lib/badgeville/activity.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#player_id ⇒ Object
Returns the value of attribute player_id.
-
#points ⇒ Object
Returns the value of attribute points.
-
#rewards ⇒ Object
Returns the value of attribute rewards.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#verb ⇒ Object
Returns the value of attribute verb.
Instance Method Summary collapse
-
#initialize(json = nil) ⇒ Activity
constructor
A new instance of Activity.
Constructor Details
#initialize(json = nil) ⇒ Activity
Returns a new instance of Activity.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/badgeville/activity.rb', line 8 def initialize(json=nil) if json @verb = json.delete("verb") @player_id = json.delete("player_id") @user_id = json.delete("user_id") @points = json.delete("points").to_i @created_at = DateTime.parse(json.delete("created_at")).to_time @rewards = json.delete("rewards").map do |award| Reward.new(award) end @meta = json.inject({}) do |, entry| k,v = entry [k.to_sym] = v end end end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def created_at @created_at end |
#meta ⇒ Object
Returns the value of attribute meta.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def @meta end |
#player_id ⇒ Object
Returns the value of attribute player_id.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def player_id @player_id end |
#points ⇒ Object
Returns the value of attribute points.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def points @points end |
#rewards ⇒ Object
Returns the value of attribute rewards.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def rewards @rewards end |
#user_id ⇒ Object
Returns the value of attribute user_id.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def user_id @user_id end |
#verb ⇒ Object
Returns the value of attribute verb.
6 7 8 |
# File 'lib/badgeville/activity.rb', line 6 def verb @verb end |