Class: Worklog::CLI
- Inherits:
-
Thor
- Object
- Thor
- Worklog::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/worklog/cli.rb
Instance Method Summary collapse
- #get ⇒ Object
- #index ⇒ Object
- #new(logname = File.basename(Dir.pwd)) ⇒ Object
- #prev(period = "month") ⇒ Object
- #this(period = "month") ⇒ Object
- #version ⇒ Object
Instance Method Details
#get ⇒ Object
45 46 47 |
# File 'lib/worklog/cli.rb', line 45 def get get_logs.each{|sh| Printer.new(Decorator.new(sh)).tracks()} end |
#index ⇒ Object
80 81 82 83 |
# File 'lib/worklog/cli.rb', line 80 def index str = Worklog.params[:index].map{|i| "- #{i}"}.join(?n) say "Worklogs were noticed in the following places:\n#{str}" end |
#new(logname = File.basename(Dir.pwd)) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/worklog/cli.rb', line 37 def new(logname = File.basename(Dir.pwd)) filename = CreateLog.(logname) exit if filename.empty? say "Worklog #{filename} created" Worklog.indexd end |
#prev(period = "month") ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/worklog/cli.rb', line 65 def prev(period = "month") get_logs.each do |sh| printer = Printer.new(Decorator.new(sh)) case period when 'month' printer.prev_month when 'week' printer.prev_week else raise ArgumentError, "Unknown period '#{period}'" end end end |
#this(period = "month") ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/worklog/cli.rb', line 50 def this(period = "month") get_logs.each do |sh| printer = Printer.new(Decorator.new(sh)) case period when 'month' printer.this_month when 'week' printer.this_week else raise ArgumentError, "Unknown period '#{period}'" end end end |