class Pathname

Customized Pathname Appended convenient methods for abbreviation

Public Instance Methods

first(n:1) click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 20
def first(n:1)
  (length > n) ? self : self.class.new(self.to_s[0..n])
end
length() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 8
def length
  #self.to_s.include?('/') ? self.to_s.size : self.to_s.count("^/")+1
  self.to_s.size
end
split_paths() click to toggle source
# File lib/enhanced_prompt/token/dir.rb, line 13
def split_paths
  # have to delete empty string to exclude first /
  paths = self.to_s.split('/')
  paths.delete('')
  paths.map{|str| self.class.new(str)}
end