class PeopleCompatible::Person
Public Class Methods
new(name, birthday)
click to toggle source
# File lib/people_compatible/person.rb, line 39 def initialize(name, birthday) @name = name @birthday = Date.parse(birthday) end
Public Instance Methods
age()
click to toggle source
# File lib/people_compatible/person.rb, line 44 def age ((DateTime.now - @birthday) / 365.25).to_i end
avg_life()
click to toggle source
# File lib/people_compatible/person.rb, line 48 def avg_life 68 end
can_marry?(person)
click to toggle source
# File lib/people_compatible/person.rb, line 56 def can_marry?(person) @can_marry = nil if person.class == Person || self.class == Person raise TypeError, 'Объект Person' end if person.class == self.class @can_marry = false end end
older_than_avg?()
click to toggle source
# File lib/people_compatible/person.rb, line 52 def older_than_avg? age > avg_life end