Class: FSSM::Pathname

Inherits:
Pathname
  • Object
show all
Defined in:
lib/fssm/pathname.rb

Constant Summary collapse

VIRTUAL_REGEX =
/^file:([^!]*)!/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[]Object



14
# File 'lib/fssm/pathname.rb', line 14

alias :[] :glob

.for(path) ⇒ Object



10
11
12
# File 'lib/fssm/pathname.rb', line 10

def for(path)
  path.is_a?(::FSSM::Pathname) ? path : new(path)
end

Instance Method Details

#glob(pattern, flags = 0, &block) ⇒ Object



30
31
32
33
34
# File 'lib/fssm/pathname.rb', line 30

def glob(pattern, flags = 0, &block)
  patterns = [pattern].flatten
  patterns.map! { |p| self.class.glob(to_s + p, flags, &block) }
  patterns.flatten
end

#is_virtual?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/fssm/pathname.rb', line 17

def is_virtual?
  !!(VIRTUAL_REGEX =~ to_s)
end

#segmentsObject



21
22
23
24
25
26
27
28
# File 'lib/fssm/pathname.rb', line 21

def segments
  path  = to_s
  array = path.split(File::SEPARATOR)
  array.delete('')
  array.insert(0, File::SEPARATOR) if path[0, 1] == File::SEPARATOR
  array[0] += File::SEPARATOR if path[0, 3] =~ SEPARATOR_PAT
  array
end