Class: Periodical::Filter::Policy
- Inherits:
-
Object
- Object
- Periodical::Filter::Policy
- Defined in:
- lib/periodical/filter.rb
Instance Attribute Summary collapse
-
#periods ⇒ Object
readonly
Returns the value of attribute periods.
Instance Method Summary collapse
- #<<(period) ⇒ Object
- #filter(values, **options, &block) ⇒ Object
-
#initialize ⇒ Policy
constructor
A new instance of Policy.
Constructor Details
#initialize ⇒ Policy
Returns a new instance of Policy.
117 118 119 |
# File 'lib/periodical/filter.rb', line 117 def initialize @periods = {} end |
Instance Attribute Details
#periods ⇒ Object (readonly)
Returns the value of attribute periods.
135 136 137 |
# File 'lib/periodical/filter.rb', line 135 def periods @periods end |
Instance Method Details
#<<(period) ⇒ Object
121 122 123 |
# File 'lib/periodical/filter.rb', line 121 def <<(period) @periods[period.class] = period end |
#filter(values, **options, &block) ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/periodical/filter.rb', line 125 def filter(values, **, &block) filtered_values = Set.new @periods.values.each do |period| filtered_values += period.filter(values, **, &block) end return filtered_values, (Set.new(values) - filtered_values) end |