Class: Abt::Providers::Asana::Path

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

Constant Summary collapse

PATH_REGEX =
%r{^(?<project_gid>\d+)?/?(?<task_gid>\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/asana/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_gids(project_gid: nil, task_gid: nil) ⇒ Object



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

def self.from_gids(project_gid: nil, task_gid: nil)
  path = project_gid ? [project_gid, *task_gid].join("/") : ""
  new(path)
end

Instance Method Details

#project_gidObject



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

def project_gid
  match[:project_gid]
end

#task_gidObject



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

def task_gid
  match[:task_gid]
end