Module: Fast

Defined in:
lib/fast/dir.rb,
lib/fast/fast.rb,
lib/fast/file.rb,
lib/fast/version.rb,
lib/fast/exceptions.rb,
lib/fast/filesystemobject.rb

Defined Under Namespace

Modules: FilesystemObject Classes: Dir, File, PathNotSettedException

Constant Summary collapse

VERSION =
"0.1.4"

Class Method Summary collapse

Class Method Details

.dir(path = nil) ⇒ Object

Returns a Dir with the file list already called (if a path is provided)



9
10
11
12
13
14
15
16
17
# File 'lib/fast/fast.rb', line 9

def self.dir path = nil
  unless path.nil?
    the_dir = Fast::Dir.new path
    the_dir.list if the_dir.exist?
    the_dir
  else 
    Fast::Dir.new
  end
end

.dir!(path) ⇒ Object

Like ‘dir`, but creates the directory if it does not exist



20
21
22
# File 'lib/fast/fast.rb', line 20

def self.dir! path
  Dir.new.create( path ).list
end

.dir?(path) ⇒ Boolean

Returns true if a directory named ‘path` exists, false otherwise. (wrapper for `File.directory? <path>`)

Returns:

  • (Boolean)


42
43
44
# File 'lib/fast/fast.rb', line 42

def self.dir? path  
  Dir.new.exist? path
end

.file(path = nil) ⇒ Object

Returns a File with its content (if a path to a valid file is provided)



25
26
27
28
29
30
31
32
33
# File 'lib/fast/fast.rb', line 25

def self.file path = nil
  if path
    the_file = Fast::File.new path 
    the_file.read if the_file.exist?
    the_file
  else 
    Fast::File.new
  end
end

.file!(path) ⇒ Object

Returns a File, and creates it if is does not exist



36
37
38
# File 'lib/fast/fast.rb', line 36

def self.file! path
  File.new.create path
end

.file?(path) ⇒ Boolean

Example. This all will be deprecated when features are done

Returns:

  • (Boolean)


47
48
49
# File 'lib/fast/fast.rb', line 47

def self.file? path
  File.new.exist? path
end