Class: SOF::Cycles::Within

Inherits:
SOF::Cycle show all
Defined in:
lib/sof/cycles/within.rb

Constant Summary

Constants inherited from SOF::Cycle

SOF::Cycle::VERSION

Instance Attribute Summary

Attributes inherited from SOF::Cycle

#parser

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SOF::Cycle

#==, #as_json, class_for_kind, class_for_notation_id, #considered_dates, #cover?, #covered_dates, cycle_handlers, dump, #expiration_of, for, #from_data, handles?, #humanized_span, inherited, #initialize, #kind_inquiry, #last_completed, legend, load, notation, #notation, #range, #satisfied_by?, #to_h, validate_period, #validate_period, volume_only?, #volume_to_delay_expiration

Constructor Details

This class inherits a constructor from SOF::Cycle

Class Method Details

.descriptionObject



13
14
15
# File 'lib/sof/cycles/within.rb', line 13

def self.description
  "Within - occurrences within a time period from a specific date"
end

.examplesObject



17
18
19
# File 'lib/sof/cycles/within.rb', line 17

def self.examples
  ["V2W3DF2024-01-01 - twice within 3 days from Jan 1, 2024"]
end

.recurring?Boolean

Returns:

  • (Boolean)


11
# File 'lib/sof/cycles/within.rb', line 11

def self.recurring? = false

Instance Method Details

#date_rangeObject



31
32
33
34
35
# File 'lib/sof/cycles/within.rb', line 31

def date_range
  return humanized_span unless active?

  [start_date, final_date].map { it.to_fs(:american) }.join(" - ")
end

#extend_period(count) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sof/cycles/within.rb', line 23

def extend_period(count)
  Cycle.for(
    Parser.load(
      parser.to_h.merge(period_count: period_count + count)
    ).to_s
  )
end

#final_date(_ = nil) ⇒ Object



37
# File 'lib/sof/cycles/within.rb', line 37

def final_date(_ = nil) = time_span.end_date(start_date)

#start_date(_ = nil) ⇒ Object



39
# File 'lib/sof/cycles/within.rb', line 39

def start_date(_ = nil) = from_date.to_date

#to_sObject



21
# File 'lib/sof/cycles/within.rb', line 21

def to_s = "#{volume}x within #{date_range}"