Class: DZT::FileStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/dzt/file_storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileStorage

Returns a new instance of FileStorage.

Parameters:

  • destination:

    Full directory in which to output tiles, defaults to ‘tiles’ in the current dir.



6
7
8
# File 'lib/dzt/file_storage.rb', line 6

def initialize(options = {})
  @store_path = options[:destination] || File.join(Dir.pwd, 'tiles')
end

Instance Method Details

#exists?Boolean

Returns:

  • (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, options = {})
  quality = options[:quality]
  file.write(dest) { self.quality = quality if quality }
end