Class: Abt::Providers::Harvest::Path
- Inherits:
-
String
- Object
- String
- Abt::Providers::Harvest::Path
- 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
-
#initialize(path = "") ⇒ Path
constructor
A new instance of Path.
- #project_id ⇒ Object
- #task_id ⇒ Object
Constructor Details
#initialize(path = "") ⇒ Path
Returns a new instance of Path.
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_id ⇒ Object
20 21 22 |
# File 'lib/abt/providers/harvest/path.rb', line 20 def project_id match[:project_id] end |
#task_id ⇒ Object
24 25 26 |
# File 'lib/abt/providers/harvest/path.rb', line 24 def task_id match[:task_id] end |