Class: InvaderZim::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/invader_zim/character.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(character_hash) ⇒ Character

Returns a new instance of Character.



6
7
8
9
# File 'lib/invader_zim/character.rb', line 6

def initialize(character_hash)
  character_hash.each {|k, v| self.send("#{k}=", v)}
  @@all << self
end

Instance Attribute Details

#affiliationObject

Returns the value of attribute affiliation.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def affiliation
  @affiliation
end

#appearanceObject

Returns the value of attribute appearance.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def appearance
  @appearance
end

#debutObject

Returns the value of attribute debut.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def debut
  @debut
end

#facts_of_doomObject

Returns the value of attribute facts_of_doom.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def facts_of_doom
  @facts_of_doom
end

#genderObject

Returns the value of attribute gender.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def gender
  @gender
end

#homeworldObject

Returns the value of attribute homeworld.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def homeworld
  @homeworld
end

#introductionObject

Returns the value of attribute introduction.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def introduction
  @introduction
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def name
  @name
end

#profile_urlObject

Returns the value of attribute profile_url.



2
3
4
# File 'lib/invader_zim/character.rb', line 2

def profile_url
  @profile_url
end

Class Method Details

.allObject



33
34
35
# File 'lib/invader_zim/character.rb', line 33

def self.all
  @@all
end

.create_from_collection(characters_array) ⇒ Object



16
17
18
# File 'lib/invader_zim/character.rb', line 16

def self.create_from_collection(characters_array)
  characters_array.each {|character| InvaderZim::Character.new(character)}
end

.find(id) ⇒ Object



29
30
31
# File 'lib/invader_zim/character.rb', line 29

def self.find(id)
  self.all[id-1]
end

.make_charactersObject



11
12
13
14
# File 'lib/invader_zim/character.rb', line 11

def self.make_characters
  characters_array = InvaderZim::Scraper.scrape_index_page('index.html')
  self.create_from_collection(characters_array)
end

Instance Method Details

#add_attributes_to_characters(character) ⇒ Object



24
25
26
27
# File 'lib/invader_zim/character.rb', line 24

def add_attributes_to_characters(character)
    attributes = InvaderZim::Scraper.scrape_profile_page(character)
    character.add_character_attributes(attributes)
end

#add_character_attributes(attributes_hash) ⇒ Object



20
21
22
# File 'lib/invader_zim/character.rb', line 20

def add_character_attributes(attributes_hash)
  attributes_hash.each {|k, v| self.send("#{k}=", v)}
end