Module: BoundedContext::PetFamily::Pets

Extended by:
ActiveSupport::Concern
Includes:
RestResource
Included in:
KB::Fake::Api
Defined in:
lib/kb/fake/bounded_context/pet_family/pets.rb

Instance Method Summary collapse

Instance Method Details

#stage(birthdate, species) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/kb/fake/bounded_context/pet_family/pets.rb', line 69

def stage(birthdate, species)
  return nil if birthdate.nil?

  case ((Time.zone.now - Time.zone.parse(birthdate)) / 1.month).to_i
  when 0..11
    species == 'cat' ? 'kitten' : 'puppy'
  when 12..99
    'adult'
  else
    'senior'
  end
end