Class: DZT::FileStorage
- Inherits:
-
Object
- Object
- DZT::FileStorage
- Defined in:
- lib/dzt/file_storage.rb
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(options = {}) ⇒ FileStorage
constructor
A new instance of FileStorage.
- #mkdir(path) ⇒ Object
- #storage_location(level) ⇒ Object
- #write(file, dest, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FileStorage
Returns a new instance of FileStorage.
6 7 8 |
# File 'lib/dzt/file_storage.rb', line 6 def initialize( = {}) @store_path = [:destination] || File.join(Dir.pwd, 'tiles') end |
Instance Method Details
#exists? ⇒ Boolean
10 11 12 |
# File 'lib/dzt/file_storage.rb', line 10 def exists? File.directory?(@store_path) && ! Dir["@{@store_path}/*"].empty? end |
#mkdir(path) ⇒ Object
18 19 20 |
# File 'lib/dzt/file_storage.rb', line 18 def mkdir(path) FileUtils.mkdir_p(path) end |
#storage_location(level) ⇒ Object
14 15 16 |
# File 'lib/dzt/file_storage.rb', line 14 def storage_location(level) File.join(@store_path, level.to_s) end |
#write(file, dest, options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/dzt/file_storage.rb', line 22 def write(file, dest, = {}) quality = [:quality] file.write(dest) { self.quality = quality if quality } end |