Module: MultiEncoder::Storage::FileSystem

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

Instance Method Summary collapse

Instance Method Details

#directoryObject



15
16
17
# File 'lib/multi_encoder/storage/filesystem.rb', line 15

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

#exists?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/multi_encoder/storage/filesystem.rb', line 23

def exists?
  file_path.exist?
end

#file_pathObject



19
20
21
# File 'lib/multi_encoder/storage/filesystem.rb', line 19

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

#rootObject



11
12
13
# File 'lib/multi_encoder/storage/filesystem.rb', line 11

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

#urlObject



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

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