class Abt::Providers::Harvest::Services::TaskPicker

Attributes

cli[R]
path[R]
project_assignment[R]

Public Class Methods

call(**args) click to toggle source
# File lib/abt/providers/harvest/services/task_picker.rb, line 17
def self.call(**args)
  new(**args).call
end
new(cli:, path:, project_assignment:) click to toggle source
# File lib/abt/providers/harvest/services/task_picker.rb, line 23
def initialize(cli:, path:, project_assignment:)
  @cli = cli
  @path = path
  @project_assignment = project_assignment
end

Public Instance Methods

call() click to toggle source
# File lib/abt/providers/harvest/services/task_picker.rb, line 29
def call
  task = cli.prompt.choice("Select a task from #{project['name']}", tasks)

  path_with_task = Path.from_ids(project_id: path.project_id, task_id: task["id"])

  Result.new(task: task, path: path_with_task)
end

Private Instance Methods

project() click to toggle source
# File lib/abt/providers/harvest/services/task_picker.rb, line 39
def project
  project_assignment["project"]
end
tasks() click to toggle source
# File lib/abt/providers/harvest/services/task_picker.rb, line 43
def tasks
  @tasks ||= project_assignment["task_assignments"].map { |ta| ta["task"] }
end