Class: TimeCamp::Timer
- Defined in:
- lib/ruby-timecamp/resources/timer.rb
Instance Attribute Summary collapse
-
#elapsed ⇒ Object
readonly
Returns the value of attribute elapsed.
-
#entry_id ⇒ Object
readonly
Returns the value of attribute entry_id.
-
#entry_time ⇒ Object
readonly
Returns the value of attribute entry_time.
-
#external_task_id ⇒ Object
readonly
Returns the value of attribute external_task_id.
-
#isTimerRunning ⇒ Object
readonly
Returns the value of attribute isTimerRunning.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#new_timer_id ⇒ Object
readonly
Returns the value of attribute new_timer_id.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#task_id ⇒ Object
readonly
Returns the value of attribute task_id.
-
#timer_id ⇒ Object
readonly
Returns the value of attribute timer_id.
Class Method Summary collapse
- .get ⇒ Object
-
.resource_name ⇒ Object
override because the path for this resource is not plural for some reason.
-
.start(opts = {}) ⇒ Object
optional :task_id, :entry_id, :started_at.
-
.stop(opts = {}) ⇒ Object
required :timer_id, :stopped_at.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from TimeCamp::Resource
Instance Attribute Details
#elapsed ⇒ Object (readonly)
Returns the value of attribute elapsed.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def elapsed @elapsed end |
#entry_id ⇒ Object (readonly)
Returns the value of attribute entry_id.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def entry_id @entry_id end |
#entry_time ⇒ Object (readonly)
Returns the value of attribute entry_time.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def entry_time @entry_time end |
#external_task_id ⇒ Object (readonly)
Returns the value of attribute external_task_id.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def external_task_id @external_task_id end |
#isTimerRunning ⇒ Object (readonly)
Returns the value of attribute isTimerRunning.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def isTimerRunning @isTimerRunning end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def name @name end |
#new_timer_id ⇒ Object (readonly)
Returns the value of attribute new_timer_id.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def new_timer_id @new_timer_id end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def start_time @start_time end |
#task_id ⇒ Object (readonly)
Returns the value of attribute task_id.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def task_id @task_id end |
#timer_id ⇒ Object (readonly)
Returns the value of attribute timer_id.
3 4 5 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 3 def timer_id @timer_id end |
Class Method Details
.get ⇒ Object
15 16 17 18 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 15 def self.get response = TimeCamp::Request.post(resource_name, {}, { action: 'status' }) return Timer.new(response) end |
.resource_name ⇒ Object
override because the path for this resource is not plural for some reason
11 12 13 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 11 def self.resource_name return 'timer' end |
.start(opts = {}) ⇒ Object
optional :task_id, :entry_id, :started_at
21 22 23 24 25 26 27 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 21 def self.start(opts={}) data_keys = [:task_id, :entry_id, :started_at] data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h) data.merge!(action: 'start') response = TimeCamp::Request.post(resource_name, opts, data) return Timer.new(response) end |
.stop(opts = {}) ⇒ Object
required :timer_id, :stopped_at
30 31 32 33 34 35 36 |
# File 'lib/ruby-timecamp/resources/timer.rb', line 30 def self.stop(opts={}) data_keys = [:timer_id, :stopped_at] data, opts = opts.partition{ |k, v| data_keys.include?(k) }.map(&:to_h) data.merge!(action: 'stop') response = TimeCamp::Request.post(resource_name, opts, data) return Timer.new(response) end |