Class: Dsu::Services::EntryGroup::CounterService

Inherits:
Object
  • Object
show all
Defined in:
lib/dsu/services/entry_group/counter_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(times:, options: {}) ⇒ CounterService

Returns a new instance of CounterService.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/dsu/services/entry_group/counter_service.rb', line 9

def initialize(times:, options: {})
  raise ArgumentError, 'Argument times is nil' if times.nil?

  @times = times
  @options = options
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
# File 'lib/dsu/services/entry_group/counter_service.rb', line 16

def call
  total_entry_groups = 0

  times.each do |time|
    total_entry_groups += 1 if Models::EntryGroup.exist?(time: time)
  end

  total_entry_groups
end