Class: Pansophy::Remote::Directory

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

Instance Method Summary collapse

Constructor Details

#initialize(bucket_name, path = nil) ⇒ Directory

Returns a new instance of Directory.



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

def initialize(bucket_name, path = nil)
  @bucket_name = bucket_name
  @path        = path.to_s
end

Instance Method Details

#create(options) ⇒ Object



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

def create(options)
  remove(options)
  directory.files.create(key: pathname.cleanpath.to_s + '/')
end

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



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

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

#filesObject



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

def files
  remote_files.map { |file| File.new(file) }
end

#pathnameObject



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

def pathname
  Pathname.new(@path)
end