Class: Petli::Pet
- Inherits:
-
Object
- Object
- Petli::Pet
- Extended by:
- Tatty::DB::Attributes
- Defined in:
- lib/petli/pet.rb,
lib/petli/pet/food.rb,
lib/petli/pet/death.rb,
lib/petli/pet/happy.rb,
lib/petli/pet/animation.rb
Defined Under Namespace
Modules: Animation, Death, Food, Happy
Constant Summary
Constants included from Happy
Constants included from Food
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize ⇒ Pet
constructor
A new instance of Pet.
- #lifetime ⇒ Object
Methods included from Tatty::DB::Attributes
Methods included from Happy
#lose, #play, #update_happiness, #win
Methods included from Food
#clean, #feed, #feed!, #update_hunger
Methods included from Death
Methods included from Animation
#animation, #atlas, #avail_animations, #busy?, #celebrate, #embarass, #hatch, #light_switch, #react, #reset, #setup_animation, #sleeping?, #update_animation
Constructor Details
#initialize ⇒ Pet
Returns a new instance of Pet.
15 16 17 18 |
# File 'lib/petli/pet.rb', line 15 def initialize super() setup_animation end |
Instance Method Details
#display ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/petli/pet.rb', line 20 def display return animation.next if self.dead? update_hunger update_happiness check_if_dead update_animation animation.display end |
#lifetime ⇒ Object
29 30 31 |
# File 'lib/petli/pet.rb', line 29 def lifetime (self.died_at.nil? ? days_since(self.birth) : days_since(self.birth, self.died_at)).to_i end |