Class: Hbtrack::RemoveCommand
- Defined in:
- lib/hbtrack/command/remove_command.rb
Instance Method Summary collapse
- #create_option_parser ⇒ Object
- #execute ⇒ Object
- #feedback(names) ⇒ Object
-
#initialize(store_path, options) ⇒ RemoveCommand
constructor
A new instance of RemoveCommand.
- #remove_from_db(names, store) ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(store_path, options) ⇒ RemoveCommand
Returns a new instance of RemoveCommand.
8 9 10 |
# File 'lib/hbtrack/command/remove_command.rb', line 8 def initialize(store_path, ) super(store_path, ) end |
Instance Method Details
#create_option_parser ⇒ Object
17 18 19 20 21 |
# File 'lib/hbtrack/command/remove_command.rb', line 17 def create_option_parser OptionParser.new do |opts| opts. = 'Usage: hbtrack remove [<habit_name>]' end end |
#execute ⇒ Object
12 13 14 15 |
# File 'lib/hbtrack/command/remove_command.rb', line 12 def execute return remove_from_db(@names, local_store) super end |
#feedback(names) ⇒ Object
23 24 25 |
# File 'lib/hbtrack/command/remove_command.rb', line 23 def feedback(names) Hbtrack::Util.blue("Remove #{names.join(',')}!") end |
#remove_from_db(names, store) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/hbtrack/command/remove_command.rb', line 27 def remove_from_db(names, store) status = store.delete_habit(names) return ErrorHandler.raise_if_habit_error(names) if status == 0 feedback(names) end |