Module: Odin::Utils::PathUtils
- Defined in:
- lib/odin/utils/path_utils.rb
Class Method Summary collapse
Class Method Details
.build(*segments) ⇒ Object
6 7 8 |
# File 'lib/odin/utils/path_utils.rb', line 6 def self.build(*segments) segments.map(&:to_s).reject(&:empty?).join(".") end |
.leaf(path) ⇒ Object
19 20 21 22 |
# File 'lib/odin/utils/path_utils.rb', line 19 def self.leaf(path) idx = path.rindex(".") idx ? path[(idx + 1)..] : path end |
.parent(path) ⇒ Object
14 15 16 17 |
# File 'lib/odin/utils/path_utils.rb', line 14 def self.parent(path) idx = path.rindex(".") idx ? path[0...idx] : nil end |
.split(path) ⇒ Object
10 11 12 |
# File 'lib/odin/utils/path_utils.rb', line 10 def self.split(path) path.scan(/[^.\[\]]+|\[\d+\]/) end |