Module: Dsu::Support::EntryGroupBrowsable

Included in:
Dsu::Subcommands::Browse
Defined in:
lib/dsu/support/entry_group_browsable.rb

Instance Method Summary collapse

Instance Method Details

#browse_entry_groups(time:, options: {}) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dsu/support/entry_group_browsable.rb', line 12

def browse_entry_groups(time:, options: {})
  raise ArgumentError, 'time must be a Time object' unless time.is_a?(Time)
  raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash)

  options = configuration.to_h.merge(options).with_indifferent_access
  times = browse_service(time: time, options: options).call
  if times.empty? || (options.fetch(:include_all, false) && no_entries_for?(times: times, options: options))
    display_no_entries_to_display_message time: time, options: options
    return
  end

  output = Services::StdoutRedirectorService.call do
    self.class.display_dsu_header
    header = browse_header_for(time: time, options: options)
    Views::Shared::Info.new(messages: header).render
    puts
    presenter = Presenters::EntryGroup::List::DatesPresenter.new(times: times, options: options)
    Views::EntryGroup::List.new(presenter: presenter).render
    self.class.display_dsu_footer
  end
  output_with_pager output: output, options: options
end