class Dotfiled::AlternativeFile::File

Public Class Methods

new(path = "") click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 6
def initialize(path = "")
  @path = Pathname.new(path.to_s)
end

Private Class Methods

join(parts) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 57
def join(parts)
  file = File.new("")
  parts.flatten.each { |part| file = file.join(part) }
  file
end

Public Instance Methods

exist?() click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 46
def exist?
  ::File.exist?(to_s)
end
gsub(find, replace) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 34
def gsub(find, replace)
  new(to_s.gsub(find, replace))
end
join(other_part) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 38
def join(other_part)
  new(@path.join(other_part.to_s))
end
match?(*args) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 22
def match?(*args)
  to_s.match?(*args)
end
prefix_with(prefix) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 42
def prefix_with(prefix)
  new(prefix).join(self)
end
split(char = "/") click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 26
def split(char = "/")
  to_s.split(char)
end
start_with?(prefix) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 14
def start_with?(prefix)
  to_s.start_with?(prefix)
end
sub(find, replace) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 30
def sub(find, replace)
  new(to_s.sub(find, replace))
end
to_s() click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 10
def to_s
  @path.to_s.gsub("//", "/")
end
without_prefix(prefix) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 18
def without_prefix(prefix)
  sub(/^#{prefix}/, "")
end

Private Instance Methods

new(path) click to toggle source
# File lib/dotfiled/alternative_file/file.rb, line 52
def new(path)
  self.class.new(path)
end