diff --git a/CHANGELOG.md b/CHANGELOG.md index c602b14..035b942 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/sof/cycle.rb b/lib/sof/cycle.rb index 9adf732..0010e51 100644 --- a/lib/sof/cycle.rb +++ b/lib/sof/cycle.rb @@ -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. diff --git a/lib/sof/cycles/end_of.rb b/lib/sof/cycles/end_of.rb index b86c572..310f257 100644 --- a/lib/sof/cycles/end_of.rb +++ b/lib/sof/cycles/end_of.rb @@ -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 diff --git a/lib/sof/cycles/within.rb b/lib/sof/cycles/within.rb index d3120cd..05ab165 100644 --- a/lib/sof/cycles/within.rb +++ b/lib/sof/cycles/within.rb @@ -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 diff --git a/lib/sof/parser.rb b/lib/sof/parser.rb index 967fd45..cdc9b3b 100644 --- a/lib/sof/parser.rb +++ b/lib/sof/parser.rb @@ -20,7 +20,9 @@ class Parser (?F(?\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