Class: NerdTown::Guild::MemberCollectionParser

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

Defined Under Namespace

Classes: GuildMember, MemberCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_collection) ⇒ MemberCollectionParser

Returns a new instance of MemberCollectionParser.



39
40
41
42
# File 'lib/nerd_town/guild.rb', line 39

def initialize(raw_collection)
  @raw_collection = raw_collection
  @collection = MemberCollection.new
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



38
39
40
# File 'lib/nerd_town/guild.rb', line 38

def collection
  @collection
end

#raw_collectionObject (readonly)

Returns the value of attribute raw_collection.



38
39
40
# File 'lib/nerd_town/guild.rb', line 38

def raw_collection
  @raw_collection
end

Instance Method Details

#parseObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/nerd_town/guild.rb', line 44

def parse
  raw_collection.each do |raw_member|
    char_attrs = raw_member["character"]
    member = GuildMember.new(name: char_attrs["name"],
                             realm: char_attrs["realm"],
                             thumbnail: char_attrs["thumbnail"],
                             class: char_attrs["class"],
                             rank: raw_member["rank"],
                             race: char_attrs["race"])

    collection.push(member)
  end

  collection
end