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.



464
465
466
467
468
469
470
471
472
# File 'lib/fugit/cron.rb', line 464

def initialize(deltas, span)

  @span = span

  @delta_min = deltas.min; @delta_max = deltas.max
  @occurrences = deltas.size
  @span_years = span / YEAR_S
  @yearly_occurrences = @occurrences.to_f / @span_years
end

Instance Attribute Details

#delta_maxObject (readonly)

Returns the value of attribute delta_max.



461
462
463
# File 'lib/fugit/cron.rb', line 461

def delta_max
  @delta_max
end

#delta_minObject (readonly)

Returns the value of attribute delta_min.



461
462
463
# File 'lib/fugit/cron.rb', line 461

def delta_min
  @delta_min
end

#occurrencesObject (readonly)

Returns the value of attribute occurrences.



461
462
463
# File 'lib/fugit/cron.rb', line 461

def occurrences
  @occurrences
end

#spanObject (readonly)

Returns the value of attribute span.



461
462
463
# File 'lib/fugit/cron.rb', line 461

def span
  @span
end

#span_yearsObject (readonly)

Returns the value of attribute span_years.



462
463
464
# File 'lib/fugit/cron.rb', line 462

def span_years
  @span_years
end

#yearly_occurrencesObject (readonly)

Returns the value of attribute yearly_occurrences.



462
463
464
# File 'lib/fugit/cron.rb', line 462

def yearly_occurrences
  @yearly_occurrences
end

Instance Method Details

#to_debug_sObject



474
475
476
477
478
479
480
481
482
483
484
# File 'lib/fugit/cron.rb', line 474

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