Class: Dsu::Services::EntryGroup::BrowseService

Inherits:
Object
  • Object
show all
Includes:
Dsu::Support::TimeFormatable, Dsu::Support::TimesSortable
Defined in:
lib/dsu/services/entry_group/browse_service.rb

Overview

This service is responsible for returning an array of sorted entry group dates as Time objects. The Time objects returned, and the sort order are determined by the options passed in.

Instance Method Summary collapse

Methods included from Dsu::Support::TimesSortable

#sorted_dsu_times_for, #times_for, #times_sort

Methods included from Dsu::Support::TimeFormatable

dd_mm_yyyy, formatted_time, mm_dd, mm_dd_yyyy, timezone_for, yyyy_mm_dd, yyyy_mm_dd_or_through_for

Constructor Details

#initialize(time:, options: {}) ⇒ BrowseService

Returns a new instance of BrowseService.

Raises:

  • (ArgumentError)


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

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

  @time = time
  @options = options
end

Instance Method Details

#callObject



26
27
28
29
30
# File 'lib/dsu/services/entry_group/browse_service.rb', line 26

def call
  return [] if entry_group_times.empty?

  times_sort(times: entry_group_times, entries_display_order: entries_display_order)
end