Class: Trebbiatrice::Harvest
- Inherits:
-
Object
- Object
- Trebbiatrice::Harvest
- Defined in:
- lib/trebbiatrice/harvest.rb
Instance Method Summary collapse
-
#initialize(login_data) ⇒ Harvest
constructor
A new instance of Harvest.
- #new_entry!(entry_data, find = true) ⇒ Object
- #projects ⇒ Object
- #toggle!(entry_id) ⇒ Object
Constructor Details
#initialize(login_data) ⇒ Harvest
Returns a new instance of Harvest.
13 14 15 |
# File 'lib/trebbiatrice/harvest.rb', line 13 def initialize(login_data) @harvest = ::Harvest.hardy_client(login_data) end |
Instance Method Details
#new_entry!(entry_data, find = true) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trebbiatrice/harvest.rb', line 21 def new_entry!(entry_data, find = true) if find project_id = entry_data[:project_id].to_s entry = @harvest.time.all.select { |entry| entry[:project_id].to_s == project_id }.last if entry toggle!(entry[:id]) entry else new_entry!(entry_data, false) end else @harvest.time.create(entry_data) end end |
#projects ⇒ Object
17 18 19 |
# File 'lib/trebbiatrice/harvest.rb', line 17 def projects @harvest.time.trackable_projects end |
#toggle!(entry_id) ⇒ Object
37 38 39 |
# File 'lib/trebbiatrice/harvest.rb', line 37 def toggle!(entry_id) @harvest.time.toggle(entry_id) end |