Module: FunWith::Files::FilePathClassMethods

Included in:
FilePath
Defined in:
lib/fun_with/files/file_path_class_methods.rb

Instance Method Summary collapse

Instance Method Details

#config_dir(*args) ⇒ Object



17
18
19
# File 'lib/fun_with/files/file_path_class_methods.rb', line 17

def config_dir( *args )
  XDG['CONFIG'].fwf_filepath.join( *args )
end

#cwd(*args) ⇒ Object

args implicitly joined to cwd



5
6
7
# File 'lib/fun_with/files/file_path_class_methods.rb', line 5

def cwd( *args )
  Dir.pwd.fwf_filepath.join( *args )
end

#data_dir(*args) ⇒ Object



21
22
23
# File 'lib/fun_with/files/file_path_class_methods.rb', line 21

def data_dir( *args )
  XDG['DATA'].fwf_filepath.join( *args )
end

#home(*args) ⇒ Object



13
14
15
# File 'lib/fun_with/files/file_path_class_methods.rb', line 13

def home( *args )
  Dir.home.fwf_filepath.join( *args )
end

#pwd(*args) ⇒ Object



9
10
11
# File 'lib/fun_with/files/file_path_class_methods.rb', line 9

def pwd( *args )
  self.cwd( *args )
end

#root(*args) ⇒ Object

Honestly this is a token attempt at Windows compatibility. This could go wrong all sorts of ways, and hasn’t been tested on Windows. More to the point, when a Windows machine has multiple drives mounted, what do you even call the root?



29
30
31
32
33
34
35
# File 'lib/fun_with/files/file_path_class_methods.rb', line 29

def root( *args )
  if self.home =~ /^[a-zA-Z]:/
    self.home.to_s[0..3].fwf_filepath.join( *args )
  else
    "/".fwf_filepath.join( *args )
  end
end