Class: TogglCLI
- Inherits:
-
Object
- Object
- TogglCLI
- Defined in:
- lib/toggl_cli.rb
Instance Method Summary collapse
-
#initialize ⇒ TogglCLI
constructor
A new instance of TogglCLI.
- #start(project, description) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ TogglCLI
Returns a new instance of TogglCLI.
6 7 8 9 10 11 12 |
# File 'lib/toggl_cli.rb', line 6 def initialize @config = YAML.load_file(File.join(Dir.home, '.toggl_cli.yml')) @toggl_api = TogglV8::API.new(@config['api_key']) @user = @toggl_api.me(all=true) @workspaces = @toggl_api.my_workspaces(@user) @workspace_id = @workspaces.first['id'] end |
Instance Method Details
#start(project, description) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/toggl_cli.rb', line 14 def start(project, description) pid = "" if @config['projects'][project] pid = @config['projects'][project] end time_entry = @toggl_api.start_time_entry({ 'pid' => pid, 'description' => "#{description}", 'wid' => @workspace_id, 'start' => @toggl_api.iso8601((Time.now).to_datetime), 'created_with' => "toggl_cli" }) end |
#stop ⇒ Object
28 29 30 31 32 33 |
# File 'lib/toggl_cli.rb', line 28 def stop current = @toggl_api.get_current_time_entry if current result = @toggl_api.stop_time_entry(current['id']) end end |