Class: AllHours::Project
- Inherits:
-
Object
- Object
- AllHours::Project
- Defined in:
- lib/all_hours/project.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#budget ⇒ Object
Returns the value of attribute budget.
-
#canSyncTasks ⇒ Object
Returns the value of attribute canSyncTasks.
-
#client ⇒ Object
Returns the value of attribute client.
-
#createdAt ⇒ Object
Returns the value of attribute createdAt.
-
#enableResourcePlanner ⇒ Object
Returns the value of attribute enableResourcePlanner.
-
#estimatesType ⇒ Object
Returns the value of attribute estimatesType.
-
#favorite ⇒ Object
Returns the value of attribute favorite.
-
#foreign ⇒ Object
Returns the value of attribute foreign.
-
#hasWebhook ⇒ Object
Returns the value of attribute hasWebhook.
-
#id ⇒ Object
Returns the value of attribute id.
-
#isTemplate ⇒ Object
Returns the value of attribute isTemplate.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#privacy ⇒ Object
Returns the value of attribute privacy.
-
#status ⇒ Object
Returns the value of attribute status.
-
#user_ids ⇒ Object
Returns the value of attribute user_ids.
-
#workspaceId ⇒ Object
Returns the value of attribute workspaceId.
-
#workspaceName ⇒ Object
Returns the value of attribute workspaceName.
Class Method Summary collapse
Instance Method Summary collapse
- #budgeted_minutes ⇒ Object
-
#initialize(data:, api:) ⇒ Project
constructor
A new instance of Project.
- #percentage_used ⇒ Object
- #remaining_minutes ⇒ Object
- #tasks(limit: 250, page: 1, excludeClosed: true, query: nil) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(data:, api:) ⇒ Project
Returns a new instance of Project.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/all_hours/project.rb', line 27 def initialize data:, api: @api = api @canSyncTasks = data["canSyncTasks"] @user_ids = data["users"] @id = data["id"] @platform = data["platform"] @name = data["name"] @createdAt = Date.parse data["createdAt"] @workspaceId = data["workspaceId"] @workspaceName = data["workspaceName"] @hasWebhook = data["hasWebhook"] @status = data["status"] @estimatesType = data["estimatesType"] @budget = data["budget"] @enableResourcePlanner = data["enableResourcePlanner"] @isTemplate = data["isTemplate"] @privacy = data["privacy"] @client = data["client"] @favorite = data["favorite"] @foreign = data["foreign"] end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def api @api end |
#budget ⇒ Object
Returns the value of attribute budget.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def budget @budget end |
#canSyncTasks ⇒ Object
Returns the value of attribute canSyncTasks.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def canSyncTasks @canSyncTasks end |
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def client @client end |
#createdAt ⇒ Object
Returns the value of attribute createdAt.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def createdAt @createdAt end |
#enableResourcePlanner ⇒ Object
Returns the value of attribute enableResourcePlanner.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def enableResourcePlanner @enableResourcePlanner end |
#estimatesType ⇒ Object
Returns the value of attribute estimatesType.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def estimatesType @estimatesType end |
#favorite ⇒ Object
Returns the value of attribute favorite.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def favorite @favorite end |
#foreign ⇒ Object
Returns the value of attribute foreign.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def foreign @foreign end |
#hasWebhook ⇒ Object
Returns the value of attribute hasWebhook.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def hasWebhook @hasWebhook end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def id @id end |
#isTemplate ⇒ Object
Returns the value of attribute isTemplate.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def isTemplate @isTemplate end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def name @name end |
#platform ⇒ Object
Returns the value of attribute platform.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def platform @platform end |
#privacy ⇒ Object
Returns the value of attribute privacy.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def privacy @privacy end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def status @status end |
#user_ids ⇒ Object
Returns the value of attribute user_ids.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def user_ids @user_ids end |
#workspaceId ⇒ Object
Returns the value of attribute workspaceId.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def workspaceId @workspaceId end |
#workspaceName ⇒ Object
Returns the value of attribute workspaceName.
7 8 9 |
# File 'lib/all_hours/project.rb', line 7 def workspaceName @workspaceName end |
Class Method Details
.all(api:, limit: 200, query: nil, platform: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/all_hours/project.rb', line 54 def self.all api:, limit: 200, query: nil, platform: nil data = api.api_call path: "projects", query: {limit: limit, query: query, platform: platform} projects = [] data.each do |project_data| projects << Project.new(api: api, data: project_data) end projects end |
Instance Method Details
#budgeted_minutes ⇒ Object
80 81 82 |
# File 'lib/all_hours/project.rb', line 80 def budgeted_minutes budget.nil? ? 0 : budget["budget"] / 60 end |
#percentage_used ⇒ Object
88 89 90 91 |
# File 'lib/all_hours/project.rb', line 88 def percentage_used return 0 unless budgeted_minutes&.positive? && remaining_minutes (((budgeted_minutes.to_f - remaining_minutes) / budgeted_minutes) * 100).round end |
#remaining_minutes ⇒ Object
84 85 86 |
# File 'lib/all_hours/project.rb', line 84 def remaining_minutes budget.nil? ? 0 : budgeted_minutes - (budget["progress"] / 60) end |
#tasks(limit: 250, page: 1, excludeClosed: true, query: nil) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/all_hours/project.rb', line 64 def tasks limit: 250, page: 1, excludeClosed: true, query: nil data = @api.api_call(path: "projects/#{@id}/tasks", query: {limit: limit, page: page, excludeClosed: excludeClosed, query: query}) tasks = [] data.each do |task_data| tasks << Task.new(api: api, data: task_data) end tasks end |
#url ⇒ Object
76 77 78 |
# File 'lib/all_hours/project.rb', line 76 def url "https://app.everhour.com/#/projects/#{id}" end |