Class: UniqSysOmega::Tariffs::RepeatingFilter
Instance Method Summary
collapse
-
#calculate_cost(computer_id, login_id, started_at, amount, options = {}) ⇒ Object
-
#permitted?(computer_id, login_id, options = {}) ⇒ Boolean
-
#process_activity(unprocessed_activity, ft, options = {}) ⇒ Object
-
#start_permitted?(computer_id, login_id, options = {}) ⇒ Boolean
Methods inherited from Filter
#initialize
Instance Method Details
#calculate_cost(computer_id, login_id, started_at, amount, options = {}) ⇒ Object
136
137
138
139
140
|
# File 'lib/repeating_filter.rb', line 136
def calculate_cost(computer_id, login_id, started_at, amount, options={})
actual_periods(started_at, amount).inject(0) do |overall, p|
overall += p[:actual].filter.calculate_cost(computer_id, login_id, p[:actual].begin, p[:actual].end-p[:actual].begin, options.merge({ :period => p[:covering].as_range }))
end
end
|
#permitted?(computer_id, login_id, options = {}) ⇒ Boolean
131
132
133
134
|
# File 'lib/repeating_filter.rb', line 131
def permitted?(computer_id, login_id, options={})
period = period_matching_time(Time.now)
period.filter.permitted?(computer_id, login_id, options.merge({ :period => period.as_range }))
end
|
#process_activity(unprocessed_activity, ft, options = {}) ⇒ Object
142
143
144
145
146
147
148
149
150
|
# File 'lib/repeating_filter.rb', line 142
def process_activity(unprocessed_activity, ft, options={})
actual_periods(unprocessed_activity.created_at, unprocessed_activity.amount).each do |p|
p[:actual].filter.process_activity(
alter_activity_period(unprocessed_activity, p[:actual].begin, p[:actual].end-p[:actual].begin),
ft,
options.merge({ :period => p[:covering].as_range})) or return false
end
true
end
|
#start_permitted?(computer_id, login_id, options = {}) ⇒ Boolean
126
127
128
129
|
# File 'lib/repeating_filter.rb', line 126
def start_permitted?(computer_id, login_id, options={})
period = period_matching_time(Time.now)
period.filter.start_permitted?(computer_id, login_id, options.merge({ :period => period.as_range }))
end
|