module TimeBoots::Measure

Constants

PLURALS

Public Class Methods

measure(from, to, options = {}) click to toggle source
# File lib/time_boots/measure.rb, line 14
def self.measure(from, to, options = {})
  select_steps(options).reverse.inject({}) do |res, step|
    span, from = Boot.get(step).measure_rem(from, to)
    res.merge(PLURALS[step] => span)
  end
end
select_steps(options) click to toggle source
# File lib/time_boots/measure.rb, line 21
def self.select_steps(options)
  steps = Boot.steps
  steps.delete(:week) if options[:weeks] == false

  if (idx = steps.index(options[:max_step]))
    steps = steps.first(idx + 1)
  end

  steps
end