Class: UniqSysOmega::Tariffs::WeekdayFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/weekday_filter.rb

Instance Method Summary collapse

Methods inherited from Filter

#initialize

Constructor Details

This class inherits a constructor from UniqSysOmega::Tariffs::Filter

Instance Method Details

#calculate_cost(computer_id, login_id, started_at, amount, options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/weekday_filter.rb', line 13

def calculate_cost(computer_id, , started_at, amount, options={})
  cost = 0
  for_each_weekday(started_at, amount) do |period_start, period_length|
    cost += @weekdays[period_start.wday].calculate_cost(computer_id, , period_start, period_length, options)
  end
  cost
end

#permitted?(computer_id, login_id, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/weekday_filter.rb', line 9

def permitted?(computer_id, , options={})
  @weekdays[Time.now.wday].permitted?(computer_id, , options)
end

#process_activity(unprocessed_activity, ft, options = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/weekday_filter.rb', line 21

def process_activity(unprocessed_activity, ft, options={})
  for_each_weekday(unprocessed_activity.created_at, unprocessed_activity.amount) do |period_start, period_length|
    @weekdays[period_start.wday].process_activity(alter_activity_period(unprocessed_activity, period_start, period_length), ft, options) or return false
  end
  true
end

#start_permitted?(computer_id, login_id, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/weekday_filter.rb', line 5

def start_permitted?(computer_id, , options={})
  @weekdays[Time.now.wday].start_permitted?(computer_id, , options)
end