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
292 293 294 295 296 297 298 299 300 |
# File 'lib/fugit/cron.rb', line 292 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.
289 290 291 |
# File 'lib/fugit/cron.rb', line 289 def delta_max @delta_max end |
#delta_min ⇒ Object (readonly)
Returns the value of attribute delta_min.
289 290 291 |
# File 'lib/fugit/cron.rb', line 289 def delta_min @delta_min end |
#occurrences ⇒ Object (readonly)
Returns the value of attribute occurrences.
289 290 291 |
# File 'lib/fugit/cron.rb', line 289 def occurrences @occurrences end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
289 290 291 |
# File 'lib/fugit/cron.rb', line 289 def span @span end |
#span_years ⇒ Object (readonly)
Returns the value of attribute span_years.
290 291 292 |
# File 'lib/fugit/cron.rb', line 290 def span_years @span_years end |
#yearly_occurrences ⇒ Object (readonly)
Returns the value of attribute yearly_occurrences.
290 291 292 |
# File 'lib/fugit/cron.rb', line 290 def yearly_occurrences @yearly_occurrences end |
Instance Method Details
#to_debug_s ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/fugit/cron.rb', line 302 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 |