Class: Warchat::Models::Character
Constant Summary
collapse
- CLASSES =
{1=>'Warrior',2=>'Paladin',3=>'Hunter',4=>'Rogue',5=>'Priest',6=>'Death Knight',7=>'Shaman',8=>'Mage',9=>'Warlock',11=>'Druid'}
- RACES =
{1=>'Human',2=>'Orc',3=>'Dwarf',4=>'Night Elf',5=>'Forsaken',6=>'Tauren',7=>'Gnome',8=>'Troll',9=>'Goblin',10=>'Blood Elf',11=>'Draenei',22=>'Worgen'}
Instance Attribute Summary
#data
Class Method Summary
collapse
Instance Method Summary
collapse
all, find, find_or_create, #id, mutex, #name, #realm, #update
Constructor Details
#initialize(data) ⇒ Character
Returns a new instance of Character.
13
14
15
16
|
# File 'lib/warchat/models/character.rb', line 13
def initialize data
super
@count = 0
end
|
Class Method Details
.online ⇒ Object
8
9
10
|
# File 'lib/warchat/models/character.rb', line 8
def online
all.select &:online?
end
|
Instance Method Details
#inspect ⇒ Object
46
47
48
|
# File 'lib/warchat/models/character.rb', line 46
def inspect
"<#{self.class.name} name:#{name.inspect} realm:#{realm.inspect} klass:#{klass.inspect} level:#{level.inspect} race:#{race.inspect}>"
end
|
#klass ⇒ Object
26
27
28
|
# File 'lib/warchat/models/character.rb', line 26
def klass
CLASSES[data['c']]
end
|
#level ⇒ Object
18
19
20
|
# File 'lib/warchat/models/character.rb', line 18
def level
data['l']
end
|
#offline ⇒ Object
42
43
44
|
# File 'lib/warchat/models/character.rb', line 42
def offline
@count -= 1
end
|
#online ⇒ Object
38
39
40
|
# File 'lib/warchat/models/character.rb', line 38
def online
@count += 1
end
|
#online? ⇒ Boolean
34
35
36
|
# File 'lib/warchat/models/character.rb', line 34
def online?
count > 0
end
|
#race ⇒ Object
30
31
32
|
# File 'lib/warchat/models/character.rb', line 30
def race
RACES[data['ra']]
end
|
#rank ⇒ Object
22
23
24
|
# File 'lib/warchat/models/character.rb', line 22
def rank
data['grank']
end
|