Class: Ptimelog::App

Inherits:
Object
  • Object
show all
Defined in:
lib/ptimelog/app.rb

Overview

Wrapper for everything

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ App

Returns a new instance of App.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ptimelog/app.rb', line 6

def initialize(args)
  @config = Configuration.instance
  command = (args[0] || :show).to_sym

  @command = case command
             when :show
               @date = NamedDate.new.date(args[1])
               Command::Show.new
             when :upload
               @date = NamedDate.new.date(args[1])
               Command::Upload.new
             when :edit
               file = args[1]
               Command::Edit.new(file)
             else
               raise ArgumentError, "Unsupported Command #{@command}"
             end
end

Instance Method Details

#runObject



25
26
27
28
29
# File 'lib/ptimelog/app.rb', line 25

def run
  @command.entries = entries if @command.needs_entries?

  @command.run
end