Class: Elekk::Achievement

Inherits:
Object
  • Object
show all
Defined in:
lib/elekk/achievement.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, opts = {}) ⇒ Achievement

Returns a new instance of Achievement.



5
6
7
8
9
10
11
12
13
# File 'lib/elekk/achievement.rb', line 5

def initialize(id, opts={})
  @id = id
  @title = opts[:title]
  @points = opts[:points]
  @icon = opts[:icon]
  @description = opts[:description]
  @category = AchievementCategory[opts[:category]]
  @completed = opts[:completed]
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def category
  @category
end

#completedObject

Returns the value of attribute completed.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def completed
  @completed
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def description
  @description
end

#iconObject

Returns the value of attribute icon.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def icon
  @icon
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def id
  @id
end

#pointsObject

Returns the value of attribute points.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def points
  @points
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/elekk/achievement.rb', line 3

def title
  @title
end

Class Method Details

.from_xml(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/elekk/achievement.rb', line 15

def self.from_xml(node)
  a = self.new(node['id'].to_i, {
    :title => node['title'].to_s,
    :points => node['points'].to_i,
    :icon => node['icon'].to_s,
    :description => node['description'].to_s,
    :category => node['categoryId'].to_i
  })
  a.completed = Time.parse(node['dateCompleted'].to_s) if node['dateCompleted']
  a
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/elekk/achievement.rb', line 27

def complete?
  return !!completed
end

#wowheadObject



31
32
33
# File 'lib/elekk/achievement.rb', line 31

def wowhead
  Wowhead::Result.new(@id, @title, Wowhead::Kind['Achievement'], @icon)
end