class MyAge::CLI
Attributes
dob[RW]
Public Instance Methods
is()
click to toggle source
# File lib/my_age/cli.rb, line 13 def is self.dob = get_date(options[:dob]) date = options[:as_of].present? ? get_date(options[:as_of]) : Date.today puts age(date) end
Private Instance Methods
date_from_active_support_core_ext_helper(date)
click to toggle source
# File lib/my_age/cli.rb, line 31 def date_from_active_support_core_ext_helper(date) dates = date.delete(')').split('(') method = dates[0].to_sym arg = dates[1] arg.nil? ? Date.today.send(method) : Date.today.send(method, arg.to_i) end
get_date(date)
click to toggle source
# File lib/my_age/cli.rb, line 21 def get_date(date) if date =~ /^\d{4}-\d{2}-\d{2}$/ DateTime.strptime(date, '%Y-%m-%d') else date_from_active_support_core_ext_helper(date) end rescue NoMethodError Date.send(date) end