Class: Fugit::Cron::Frequency
- Inherits:
-
Object
- Object
- Fugit::Cron::Frequency
- Defined in:
- lib/fugit/cron.rb
Instance Attribute Summary collapse
-
#delta_max ⇒ Object
readonly
Returns the value of attribute delta_max.
-
#delta_min ⇒ Object
readonly
Returns the value of attribute delta_min.
-
#occurrences ⇒ Object
readonly
Returns the value of attribute occurrences.
-
#span ⇒ Object
readonly
Returns the value of attribute span.
-
#span_years ⇒ Object
readonly
Returns the value of attribute span_years.
-
#yearly_occurrences ⇒ Object
readonly
Returns the value of attribute yearly_occurrences.
Instance Method Summary collapse
-
#initialize(deltas, span) ⇒ Frequency
constructor
A new instance of Frequency.
- #to_debug_s ⇒ Object
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_max ⇒ Object (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_min ⇒ Object (readonly)
Returns the value of attribute delta_min.
351 352 353 |
# File 'lib/fugit/cron.rb', line 351 def delta_min @delta_min end |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
351 352 353 |
# File 'lib/fugit/cron.rb', line 351 def occurrences @occurrences end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
351 352 353 |
# File 'lib/fugit/cron.rb', line 351 def span @span end |
#span_years ⇒ Object (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_occurrences ⇒ Object (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_s ⇒ Object
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 |