Class: Abt::Providers::Harvest::Services::TaskPicker

Inherits:
Object
  • Object
show all
Defined in:
lib/abt/providers/harvest/services/task_picker.rb

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli:, path:, project_assignment:) ⇒ TaskPicker

Returns a new instance of TaskPicker.



23
24
25
26
27
# 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

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



21
22
23
# File 'lib/abt/providers/harvest/services/task_picker.rb', line 21

def cli
  @cli
end

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/abt/providers/harvest/services/task_picker.rb', line 21

def path
  @path
end

#project_assignmentObject (readonly)

Returns the value of attribute project_assignment.



21
22
23
# File 'lib/abt/providers/harvest/services/task_picker.rb', line 21

def project_assignment
  @project_assignment
end

Class Method Details

.call(**args) ⇒ Object



17
18
19
# File 'lib/abt/providers/harvest/services/task_picker.rb', line 17

def self.call(**args)
  new(**args).call
end

Instance Method Details

#callObject



29
30
31
32
33
34
35
# 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