Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1.13] - Unreleased

### Changed

- Dormant capability is now declared on each cycle class (`def self.dormant_capable? = true`) instead of only in `Parser.dormant_capable_kinds`

## [0.1.12] - 2025-09-05

### Added
Expand Down
2 changes: 2 additions & 0 deletions lib/sof/cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def legend
attr_reader :notation_id, :kind, :valid_periods
def volume_only? = @volume_only

def dormant_capable? = false

def recurring? = raise "#{name} must implement #{__method__}"

# Raises an error if the given period isn't in the list of valid periods.
Expand Down
2 changes: 2 additions & 0 deletions lib/sof/cycles/end_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class EndOf < Cycle

def self.recurring? = true

def self.dormant_capable? = true

def self.description
"End of - occurrences by the end of a time period"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/sof/cycles/within.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Within < Cycle

def self.recurring? = false

def self.dormant_capable? = true

def self.description
"Within - occurrences within a time period from a specific date"
end
Expand Down
4 changes: 3 additions & 1 deletion lib/sof/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class Parser
(?<from>F(?<from_date>\d{4}-\d{2}-\d{2}))?$ # optional from
/ix

def self.dormant_capable_kinds = %w[E W]
def self.dormant_capable_kinds
Cycle.cycle_handlers.select(&:dormant_capable?).map(&:notation_id).compact
end

def self.for(notation_or_parser)
return notation_or_parser if notation_or_parser.is_a? self
Expand Down
Loading