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, #cover?, #covered_dates, cycle_handlers, dump, #expiration_of, for, #from_data, handles?, #humanized_span, inherited, #initialize, #kind_inquiry, #last_completed, 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

.recurring?Boolean

Returns:

  • (Boolean)


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

def self.recurring? = false

Instance Method Details

#date_rangeObject



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

def date_range
  return humanized_span unless active?

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

#extend_period(count) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/sof/cycles/within.rb', line 15

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

#final_date(_ = nil) ⇒ Object



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

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

#start_date(_ = nil) ⇒ Object



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

def start_date(_ = nil) = from_date.to_date

#to_sObject



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

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