Class: Abt::Providers::Harvest::Services::ProjectPicker

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

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli:, project_assignments:) ⇒ ProjectPicker

Returns a new instance of ProjectPicker.



23
24
25
26
# File 'lib/abt/providers/harvest/services/project_picker.rb', line 23

def initialize(cli:, project_assignments:)
  @cli = cli
  @project_assignments = project_assignments
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



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

def cli
  @cli
end

#project_assignmentsObject (readonly)

Returns the value of attribute project_assignments.



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

def project_assignments
  @project_assignments
end

Class Method Details

.call(**args) ⇒ Object



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

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

Instance Method Details

#callObject



28
29
30
31
32
33
34
# File 'lib/abt/providers/harvest/services/project_picker.rb', line 28

def call
  project = cli.prompt.search("Select a project", searchable_projects)["project"]

  path = Path.from_ids(project_id: project["id"])

  Result.new(project: project, path: path)
end