Class: Armory::Guild

Inherits:
Object
  • Object
show all
Defined in:
lib/armory/guild.rb

Defined Under Namespace

Classes: Character

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGuild

Returns a new instance of Guild.



5
6
7
# File 'lib/armory/guild.rb', line 5

def initialize
  @characters = []
end

Instance Attribute Details

#charactersObject

Returns the value of attribute characters.



3
4
5
# File 'lib/armory/guild.rb', line 3

def characters
  @characters
end

#faction_idObject

Returns the value of attribute faction_id.



3
4
5
# File 'lib/armory/guild.rb', line 3

def faction_id
  @faction_id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/armory/guild.rb', line 3

def name
  @name
end

#realmObject

Returns the value of attribute realm.



3
4
5
# File 'lib/armory/guild.rb', line 3

def realm
  @realm
end

Class Method Details

.from_armory(doc) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/armory/guild.rb', line 13

def self.from_armory(doc)
  Guild.new.tap do |guild|
    info   = doc.css("guildInfo")
    header = info.css("guildHeader")

    guild.name       = header.attr("name").value
    guild.realm      = header.attr("realm").value
    guild.faction_id = header.attr("faction").value.to_i

    info.css("guild members character").each do |member|
      guild.characters << Armory::Guild::Character.new(
        member.attr('name'),
        member.attr('rank').to_i,
        member.attr('level').to_i,
        member.attr('classId').to_i,
        member.attr('genderId').to_i,
        member.attr('raceId').to_i
      )
    end
  end
end

Instance Method Details

#factionObject



9
10
11
# File 'lib/armory/guild.rb', line 9

def faction
  Armory::Factions[faction_id]
end