Class: Abt::Providers::Harvest::Path

Inherits:
String
  • Object
show all
Defined in:
lib/abt/providers/harvest/path.rb

Constant Summary collapse

PATH_REGEX =
%r{^(?<project_id>\d+)?/?(?<task_id>\d+)?$}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = "") ⇒ Path

Returns a new instance of Path.

Raises:



14
15
16
17
18
# File 'lib/abt/providers/harvest/path.rb', line 14

def initialize(path = "")
  raise Abt::Cli::Abort, "Invalid path: #{path}" unless PATH_REGEX.match?(path)

  super
end

Class Method Details

.from_ids(project_id: nil, task_id: nil) ⇒ Object



9
10
11
12
# File 'lib/abt/providers/harvest/path.rb', line 9

def self.from_ids(project_id: nil, task_id: nil)
  path = project_id ? [project_id, *task_id].join("/") : ""
  new(path)
end

Instance Method Details

#project_idObject



20
21
22
# File 'lib/abt/providers/harvest/path.rb', line 20

def project_id
  match[:project_id]
end

#task_idObject



24
25
26
# File 'lib/abt/providers/harvest/path.rb', line 24

def task_id
  match[:task_id]
end