Class: Pansophy::Local::Directory

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/pansophy/local/directory.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Directory

Returns a new instance of Directory.



6
7
8
9
# File 'lib/pansophy/local/directory.rb', line 6

def initialize(path)
  @path = path
  verify_directory!
end

Instance Method Details

#create(options) ⇒ Object



20
21
22
23
# File 'lib/pansophy/local/directory.rb', line 20

def create(options)
  remove(options)
  pathname.mkpath
end

#create_file(path, body, options = {}) ⇒ Object



25
26
27
# File 'lib/pansophy/local/directory.rb', line 25

def create_file(path, body, options = {})
  CreateFile.new(pathname.join(path), body).call(options)
end

#filesObject



16
17
18
# File 'lib/pansophy/local/directory.rb', line 16

def files
  entries.select(&:file?).map { |file| File.new(file) }
end

#pathnameObject



11
12
13
# File 'lib/pansophy/local/directory.rb', line 11

def pathname
  Pathname.new(@path)
end