Module: Petli::Pet::Death

Extended by:
Tatty::DB::Attributes
Included in:
Petli::Pet
Defined in:
lib/petli/pet/death.rb

Instance Method Summary collapse

Methods included from Tatty::DB::Attributes

db_attr

Instance Method Details

#check_if_deadObject



8
9
10
11
12
13
14
# File 'lib/petli/pet/death.rb', line 8

def check_if_dead
  not_happy = self.happiness <= 1
  not_healthy = self.health <= 1
  is_sick = self.sick > 2
  too_much_time = days_since(self.last_meal) >= 1
  self.died_at = Time.now if not_happy && not_healthy && (is_sick || too_much_time)
end

#dead?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/petli/pet/death.rb', line 16

def dead?
  !self.died_at.nil?
end