Class: Notebook::StorageAdapters::Filesystem
- Defined in:
- lib/notebook/storage_adapters/filesystem.rb
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attachment, options = {}) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #upload ⇒ Object
- #url ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attachment, options = {}) ⇒ Filesystem
Returns a new instance of Filesystem.
6 7 8 9 |
# File 'lib/notebook/storage_adapters/filesystem.rb', line 6 def initialize(, = {}) super @storage_directory = .fetch('storage_directory', Notebook.public_directory) end |
Instance Method Details
#delete ⇒ Object
11 12 13 |
# File 'lib/notebook/storage_adapters/filesystem.rb', line 11 def delete !!FileUtils.remove(url) end |
#upload ⇒ Object
15 16 17 18 |
# File 'lib/notebook/storage_adapters/filesystem.rb', line 15 def upload # When this command is successful, it returns nil FileUtils.copy(.file, @storage_directory).nil? end |
#url ⇒ Object
20 21 22 |
# File 'lib/notebook/storage_adapters/filesystem.rb', line 20 def url (@storage_directory + File.basename(.file)).to_s end |