Class: Evernotable::Command::Task
- Defined in:
- lib/evernotable/command/task.rb
Instance Method Summary collapse
Methods inherited from Base
#authenticate_user, #initialize, #invoke_client, #note_client
Methods included from Utilities
#display, #encrypt_key, #error, #format_with_bang, #output_with_bang, #read_from_file, #wrap_enml, #write_to_file
Constructor Details
This class inherits a constructor from Evernotable::Command::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/evernotable/command/task.rb', line 38 def method_missing(method_name, *args) case method_name when :help then display '--------------------------------------------' display '# add a new task evernotable task add shave my beard!' display '# list all existing tasks evernotable task list' display '# remove an existing task evernotable task remove #2 => removes task listed #2' display '--------------------------------------------' end end |
Instance Method Details
#add ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/evernotable/command/task.rb', line 5 def add invoke_client do unless @args.empty? note_client.add_note(@args.first) display 'Done.' else display 'Nothing to add!' end end end |
#list ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/evernotable/command/task.rb', line 16 def list invoke_client do notes = note_client.list_notes if notes.empty? display 'No tasks!' else notes.collect{|n| n.title}.each_with_index{|n, i| display "#{i+1}. #{n}"} end end end |
#remove ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/evernotable/command/task.rb', line 27 def remove invoke_client do unless @args.empty? note_client.remove_note(@args.first) display 'Done.' else display 'Nothing to remove!' end end end |