Module: Petli::Pet::Death
Instance Method Summary collapse
- #check_if_dead ⇒ Object
- #dead? ⇒ Boolean
- #die! ⇒ Object
- #lifetime ⇒ Object
- #sick? ⇒ Boolean
- #too_hungry? ⇒ Boolean
- #too_sick? ⇒ Boolean
- #unhappy? ⇒ Boolean
- #unhealthy? ⇒ Boolean
Methods included from Tatty::DB::Attributes
Instance Method Details
#check_if_dead ⇒ Object
8 9 10 |
# File 'lib/petli/pet/death.rb', line 8 def check_if_dead die! if unhappy? && unhealthy? && (too_sick? || too_hungry?) end |
#dead? ⇒ Boolean
36 37 38 |
# File 'lib/petli/pet/death.rb', line 36 def dead? !self.died_at.nil? end |
#die! ⇒ Object
12 13 14 |
# File 'lib/petli/pet/death.rb', line 12 def die! self.died_at = Time.now end |
#lifetime ⇒ Object
40 41 42 |
# File 'lib/petli/pet/death.rb', line 40 def lifetime (self.died_at.nil? ? days_since(self.birth) : days_since(self.birth, self.died_at)).to_i end |
#sick? ⇒ Boolean
16 17 18 |
# File 'lib/petli/pet/death.rb', line 16 def sick? self.sick > 0 end |
#too_hungry? ⇒ Boolean
24 25 26 |
# File 'lib/petli/pet/death.rb', line 24 def too_hungry? days_since(self.last_meal) >= 1 end |
#too_sick? ⇒ Boolean
20 21 22 |
# File 'lib/petli/pet/death.rb', line 20 def too_sick? self.sick > 2 end |
#unhappy? ⇒ Boolean
28 29 30 |
# File 'lib/petli/pet/death.rb', line 28 def unhappy? self.happiness <= 1 end |
#unhealthy? ⇒ Boolean
32 33 34 |
# File 'lib/petli/pet/death.rb', line 32 def unhealthy? self.health <= 1 end |