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 = {}) ⇒ Object
-
#initialize ⇒ Policy
constructor
A new instance of Policy.
Constructor Details
#initialize ⇒ Policy
Returns a new instance of Policy.
108 109 110 |
# File 'lib/periodical/filter.rb', line 108 def initialize @periods = {} end |
Instance Attribute Details
#periods ⇒ Object (readonly)
Returns the value of attribute periods.
126 127 128 |
# File 'lib/periodical/filter.rb', line 126 def periods @periods end |
Instance Method Details
#<<(period) ⇒ Object
112 113 114 |
# File 'lib/periodical/filter.rb', line 112 def <<(period) @periods[period.class] = period end |
#filter(values, options = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/periodical/filter.rb', line 116 def filter(values, = {}) filtered_values = Set.new @periods.values.each do |period| filtered_values += period.filter(values, ) end return filtered_values, (Set.new(values) - filtered_values) end |