Module: MultiEncoder::Storage::FileSystem

Defined in:
lib/multi_encoder/storage/filesystem.rb

Instance Method Summary collapse

Instance Method Details

#directoryObject



13
14
15
# File 'lib/multi_encoder/storage/filesystem.rb', line 13

def directory
  root.join 'public', 'system', type, *fingerprint
end

#exists?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/multi_encoder/storage/filesystem.rb', line 21

def exists?
  file_path.exist?
end

#file_pathObject



17
18
19
# File 'lib/multi_encoder/storage/filesystem.rb', line 17

def file_path
  Pathname.new "#{directory.join(@contents)}.#{MultiEncoder::BarcodeImage::OUTPUT_FORMAT}"
end

#rootObject



9
10
11
# File 'lib/multi_encoder/storage/filesystem.rb', line 9

def root
  defined?(Rails) ? Rails.root : Pathname.new('/tmp')
end

#urlObject



5
6
7
# File 'lib/multi_encoder/storage/filesystem.rb', line 5

def url
  file_path.to_s.gsub Rails.root.join('public').to_s, ''
end