Class: Dsu::Subcommands::Edit

Inherits:
BaseSubcommand show all
Defined in:
lib/dsu/subcommands/edit.rb

Instance Method Summary collapse

Methods included from Dsu::Support::Ask

#ask_while, #yes?

Methods inherited from BaseCLI

date_option_description, exit_on_failure?, #initialize, mnemonic_option_description

Methods included from Dsu::Support::TimesSortable

#sorted_dsu_times_for, #times_for, #times_sort

Methods included from Dsu::Support::CommandHookable

included

Methods included from Dsu::Support::CommandHelpColorizable

included

Methods included from Dsu::Support::ColorThemable

apply_theme, #prompt_with_options

Constructor Details

This class inherits a constructor from Dsu::BaseCLI

Instance Method Details

#date(date) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/dsu/subcommands/edit.rb', line 18

def date(date)
  entry_group = Models::EntryGroup.edit(time: Time.parse(date))
  Views::EntryGroup::Show.new(entry_group: entry_group).render
rescue ArgumentError => e
  puts apply_theme(I18n.t('errors.error', message: e.message), theme_color: color_theme.error)
  exit 1
end

#todayObject



28
29
30
31
# File 'lib/dsu/subcommands/edit.rb', line 28

def today
  entry_group = Models::EntryGroup.edit(time: Time.now)
  Views::EntryGroup::Show.new(entry_group: entry_group).render
end

#tomorrowObject



35
36
37
38
# File 'lib/dsu/subcommands/edit.rb', line 35

def tomorrow
  entry_group = Models::EntryGroup.edit(time: Time.now.tomorrow)
  Views::EntryGroup::Show.new(entry_group: entry_group).render
end

#yesterdayObject



42
43
44
45
# File 'lib/dsu/subcommands/edit.rb', line 42

def yesterday
  entry_group = Models::EntryGroup.edit(time: Time.now.yesterday)
  Views::EntryGroup::Show.new(entry_group: entry_group).render
end