Class: Dsu::Subcommands::Delete
- Inherits:
-
BaseSubcommand
- Object
- Thor
- BaseCLI
- BaseSubcommand
- Dsu::Subcommands::Delete
- Defined in:
- lib/dsu/subcommands/delete.rb
Constant Summary
Constants included from Dsu::Support::CommandOptions::TimeMnemonics
Dsu::Support::CommandOptions::TimeMnemonics::RELATIVE_REGEX, Dsu::Support::CommandOptions::TimeMnemonics::TODAY, Dsu::Support::CommandOptions::TimeMnemonics::TOMORROW, Dsu::Support::CommandOptions::TimeMnemonics::YESTERDAY
Instance Method Summary collapse
- #date(date_or_mnemonic) ⇒ Object
- #dates ⇒ Object
- #today ⇒ Object
- #tomorrow ⇒ Object
- #yesterday ⇒ Object
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
Methods included from Dsu::Support::CommandOptions::TimeMnemonic
relative_time_mnemonic?, time_from_mnemonic, time_from_mnemonic!, time_mnemonic?
Methods included from Dsu::Support::Ask
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
Methods included from Dsu::Support::CommandHelpColorizable
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_or_mnemonic) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dsu/subcommands/delete.rb', line 51 def date(date_or_mnemonic) time = if time_mnemonic?(date_or_mnemonic) time_from_mnemonic(command_option: date_or_mnemonic) else Time.parse(date_or_mnemonic) end delete_entry_groups_if times: [time], options: rescue ArgumentError => e Views::Shared::Error.new(messages: e.).render end |
#dates ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dsu/subcommands/delete.rb', line 69 def dates = configuration.to_h.merge(self.).with_indifferent_access times, errors = Support::CommandOptions::DsuTimes.dsu_times_for(from_option: [:from], to_option: [:to]) # rubocop:disable Layout/LineLength if errors.any? Views::Shared::Error.new(messages: errors).render return end times = times_sort(times: times, entries_display_order: [:entries_display_order]) delete_entry_groups_if times: times, options: rescue ArgumentError => e Views::Shared::Error.new(messages: e.).render end |
#today ⇒ Object
28 29 30 |
# File 'lib/dsu/subcommands/delete.rb', line 28 def today delete_entry_groups_if times: [Time.now], options: end |
#tomorrow ⇒ Object
35 36 37 |
# File 'lib/dsu/subcommands/delete.rb', line 35 def tomorrow delete_entry_groups_if times: [Time.now.tomorrow], options: end |
#yesterday ⇒ Object
42 43 44 |
# File 'lib/dsu/subcommands/delete.rb', line 42 def yesterday delete_entry_groups_if times: [Time.now.yesterday], options: end |