Class: Fugit::Cron::Frequency

Inherits:
Object
  • Object
show all
Defined in:
lib/fugit/cron.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deltas, span) ⇒ Frequency

Returns a new instance of Frequency.



354
355
356
357
358
359
360
361
362
# File 'lib/fugit/cron.rb', line 354

def initialize(deltas, span)

  @span = span

  @delta_min = deltas.min; @delta_max = deltas.max
  @occurrences = deltas.size
  @span_years = span / (365 * 24 * 3600)
  @yearly_occurrences = @occurrences.to_f / @span_years
end

Instance Attribute Details

#delta_maxObject (readonly)

Returns the value of attribute delta_max.



351
352
353
# File 'lib/fugit/cron.rb', line 351

def delta_max
  @delta_max
end

#delta_minObject (readonly)

Returns the value of attribute delta_min.



351
352
353
# File 'lib/fugit/cron.rb', line 351

def delta_min
  @delta_min
end

#occurrencesObject (readonly)

Returns the value of attribute occurrences.



351
352
353
# File 'lib/fugit/cron.rb', line 351

def occurrences
  @occurrences
end

#spanObject (readonly)

Returns the value of attribute span.



351
352
353
# File 'lib/fugit/cron.rb', line 351

def span
  @span
end

#span_yearsObject (readonly)

Returns the value of attribute span_years.



352
353
354
# File 'lib/fugit/cron.rb', line 352

def span_years
  @span_years
end

#yearly_occurrencesObject (readonly)

Returns the value of attribute yearly_occurrences.



352
353
354
# File 'lib/fugit/cron.rb', line 352

def yearly_occurrences
  @yearly_occurrences
end

Instance Method Details

#to_debug_sObject



364
365
366
367
368
369
370
371
372
373
374
# File 'lib/fugit/cron.rb', line 364

def to_debug_s

  {
    dmin: Fugit::Duration.new(delta_min).deflate.to_plain_s,
    dmax: Fugit::Duration.new(delta_max).deflate.to_plain_s,
    ocs: occurrences,
    spn: Fugit::Duration.new(span.to_i).deflate.to_plain_s,
    spnys: span_years.to_i,
    yocs: yearly_occurrences.to_i
  }.collect { |k, v| "#{k}: #{v}" }.join(', ')
end