Class: Mondex::Monster
- Inherits:
-
Object
- Object
- Mondex::Monster
- Extended by:
- Concerns::Findable
- Defined in:
- lib/mondex/monster.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#bio ⇒ Object
Returns the value of attribute bio.
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#locations ⇒ Object
Returns the value of attribute locations.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resistances ⇒ Object
Returns the value of attribute resistances.
-
#species ⇒ Object
readonly
Returns the value of attribute species.
-
#url ⇒ Object
Returns the value of attribute url.
-
#weakness ⇒ Object
Returns the value of attribute weakness.
Class Method Summary collapse
Instance Method Summary collapse
- #add_attributes(hash) ⇒ Object
- #add_species(species) ⇒ Object
-
#initialize(monster_hash) ⇒ Monster
constructor
A new instance of Monster.
Methods included from Concerns::Findable
Constructor Details
#initialize(monster_hash) ⇒ Monster
Returns a new instance of Monster.
8 9 10 11 12 13 |
# File 'lib/mondex/monster.rb', line 8 def initialize(monster_hash) monster_hash.each do |attribute, value| self.send("#{attribute}=", value) end @@all << self end |
Instance Attribute Details
#bio ⇒ Object
Returns the value of attribute bio.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def bio @bio end |
#elements ⇒ Object
Returns the value of attribute elements.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def elements @elements end |
#locations ⇒ Object
Returns the value of attribute locations.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def locations @locations end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def name @name end |
#resistances ⇒ Object
Returns the value of attribute resistances.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def resistances @resistances end |
#species ⇒ Object (readonly)
Returns the value of attribute species.
4 5 6 |
# File 'lib/mondex/monster.rb', line 4 def species @species end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def url @url end |
#weakness ⇒ Object
Returns the value of attribute weakness.
3 4 5 |
# File 'lib/mondex/monster.rb', line 3 def weakness @weakness end |
Class Method Details
.all ⇒ Object
15 16 17 |
# File 'lib/mondex/monster.rb', line 15 def self.all @@all end |
Instance Method Details
#add_attributes(hash) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mondex/monster.rb', line 29 def add_attributes(hash) hash.each do |attribute, value| if attribute == :species new_species = Mondex::Species.create_or_find_by_name(value) self.add_species(new_species) new_species.add_monster(self) else self.send("#{attribute}=", value) end end self end |
#add_species(species) ⇒ Object
25 26 27 |
# File 'lib/mondex/monster.rb', line 25 def add_species(species) @species = species end |