Class: Pathname
- Inherits:
-
Object
- Object
- Pathname
- Defined in:
- lib/vendor/fssm/ext.rb
Constant Summary collapse
- CHOP_PAT =
before overwriting chop_basename:
%total - 29.50% %self - 20.50%
after overwriting chop_basename:
%total - 24.36% %self - 15.47%
/\A#{SEPARATOR_PAT}?\z/
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.for(path) ⇒ Object
3 4 5 |
# File 'lib/vendor/fssm/ext.rb', line 3 def for(path) path.is_a?(Pathname) ? path : new(path) end |
Instance Method Details
#chop_basename(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vendor/fssm/ext.rb', line 15 def chop_basename(path) base = File.basename(path) # the original version of this method recalculates this regexp # each run, despite the pattern never changing. if CHOP_PAT =~ base return nil else return path[0, path.rindex(base)], base end end |
#names ⇒ Object
33 34 35 36 |
# File 'lib/vendor/fssm/ext.rb', line 33 def names prefix, names = split_names(@path) names end |
#segments ⇒ Object
26 27 28 29 30 31 |
# File 'lib/vendor/fssm/ext.rb', line 26 def segments prefix, names = split_names(@path) names.unshift(prefix) unless prefix.empty? names.shift if names[0] == '.' names end |