module MudratProjector::DateDiff
Constants
- Calculator
Public Instance Methods
advance(intervals: nil, unit: nil, from: nil)
click to toggle source
# File lib/mudrat_projector/date_diff.rb, line 5 def advance intervals: nil, unit: nil, from: nil fetch_subclass(unit).advance intervals, from: from end
date_diff(*maybe_unit_from_to, unit: nil, from: nil, to: nil)
click to toggle source
# File lib/mudrat_projector/date_diff.rb, line 9 def date_diff *maybe_unit_from_to, unit: nil, from: nil, to: nil if [unit, from, to].all? &:nil? unit, from, to = maybe_unit_from_to end fetch_subclass(unit).new(from, to).calculate end
Private Instance Methods
fetch_subclass(unit)
click to toggle source
# File lib/mudrat_projector/date_diff.rb, line 16 def fetch_subclass unit klass_bit = unit.to_s.capitalize.gsub(/_[a-z]/) do |dash_letter| dash_letter[1].upcase end klass_name = "#{klass_bit}Calculator" DateDiff.const_get klass_name end