Permalink
Browse files

Use correct types for achievement attributes

Signed-off-by: Peter Wood <peter@alastria.net>
  • Loading branch information...
1 parent dea0d84 commit 2cd41cdfceecdfe9d6022bc2893c4d7cd317542e @renchap renchap committed with pwood Mar 24, 2009
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/wowr/achievements.rb
View
11 lib/wowr/achievements.rb
@@ -20,10 +20,10 @@ class Achievement
attr_reader :desc, :title, :category_id, :icon, :id, :points, :title
def initialize achievement
@desc = achievement['desc']
- @category_id = achievement['categoryId']
+ @category_id = achievement['categoryId'].to_i
@icon = achievement['icon']
- @id = achievement['id']
- @points = achievement['points']
+ @id = achievement['id'].to_i
+ @points = achievement['points'].to_i
@title = achievement['title']
end
end
@@ -33,6 +33,11 @@ class CompletedAchievement < Achievement
def initialize achievement
super(achievement)
@date_completed = achievement['dateCompleted']
+ begin
+ @date_completed = achievement[:dateCompleted] == "" ? nil : DateTime.parse(achievement[:dateCompleted])
+ rescue
+ @date_completed = achievement[:dateCompleted] == "" ? nil : achievement[:dateCompleted]
+ end
end
end
end

0 comments on commit 2cd41cd

Please sign in to comment.