Sha256: 2fca3ccae79cbc8d214d1589261c0ff9e1290c8bbee0a59d112396046ba5e51f
Contents?: true
Size: 706 Bytes
Versions: 2
Compression:
Stored size: 706 Bytes
Contents
require 'time_boots' module Reality # @private # Just assorted "cool things", included into all entities # Subject to change/refactor module Helpers def alive? !birthday.nil? && date_of_death.nil? end def dead? !date_of_death.nil? end def age_at(tm) # TimeBoots fail with Time vs Date :( #birthday && TimeBoots.year.measure(birthday, tm) from = birthday || created_at || published_at if from.month < tm.month || from.month == tm.month && from.day <= tm.day tm.year - from.year else tm.year - from.year - 1 end end def age age_at(Date.today) end end Reality::Entity.include Helpers end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reality-0.0.5 | lib/reality/definitions/helpers.rb |
reality-0.0.4 | lib/reality/definitions/helpers.rb |