Class: Periodical::Filter::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/periodical/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePolicy

Returns a new instance of Policy.



117
118
119
# File 'lib/periodical/filter.rb', line 117

def initialize
	@periods = {}
end

Instance Attribute Details

#periodsObject (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, **options, &block)
	filtered_values = Set.new

	@periods.values.each do |period|
		filtered_values += period.filter(values, **options, &block)
	end

	return filtered_values, (Set.new(values) - filtered_values)
end