Class: InvaderZim::Character
- Inherits:
-
Object
- Object
- InvaderZim::Character
- Defined in:
- lib/invader_zim/character.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#affiliation ⇒ Object
Returns the value of attribute affiliation.
-
#appearance ⇒ Object
Returns the value of attribute appearance.
-
#debut ⇒ Object
Returns the value of attribute debut.
-
#facts_of_doom ⇒ Object
Returns the value of attribute facts_of_doom.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#homeworld ⇒ Object
Returns the value of attribute homeworld.
-
#introduction ⇒ Object
Returns the value of attribute introduction.
-
#name ⇒ Object
Returns the value of attribute name.
-
#profile_url ⇒ Object
Returns the value of attribute profile_url.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_collection(characters_array) ⇒ Object
- .find(id) ⇒ Object
- .make_characters ⇒ Object
Instance Method Summary collapse
- #add_attributes_to_characters(character) ⇒ Object
- #add_character_attributes(attributes_hash) ⇒ Object
-
#initialize(character_hash) ⇒ Character
constructor
A new instance of Character.
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
#affiliation ⇒ Object
Returns the value of attribute affiliation.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def affiliation @affiliation end |
#appearance ⇒ Object
Returns the value of attribute appearance.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def appearance @appearance end |
#debut ⇒ Object
Returns the value of attribute debut.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def debut @debut end |
#facts_of_doom ⇒ Object
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 |
#gender ⇒ Object
Returns the value of attribute gender.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def gender @gender end |
#homeworld ⇒ Object
Returns the value of attribute homeworld.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def homeworld @homeworld end |
#introduction ⇒ Object
Returns the value of attribute introduction.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def introduction @introduction end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/invader_zim/character.rb', line 2 def name @name end |
#profile_url ⇒ Object
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
.all ⇒ Object
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_characters ⇒ Object
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 |