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.
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_max ⇒ Object (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_min ⇒ Object (readonly)
Returns the value of attribute delta_min.
461 462 463 |
# File 'lib/fugit/cron.rb', line 461 def delta_min @delta_min end |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
461 462 463 |
# File 'lib/fugit/cron.rb', line 461 def occurrences @occurrences end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
461 462 463 |
# File 'lib/fugit/cron.rb', line 461 def span @span end |
#span_years ⇒ Object (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_occurrences ⇒ Object (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_s ⇒ Object
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 |