Module: Basil::Barcodes

Defined in:
lib/basil/barcodes.rb

Class Method Summary collapse

Class Method Details

.barcode_filesObject

list available barcodes files



10
11
12
# File 'lib/basil/barcodes.rb', line 10

def self.barcode_files
  Dir[File.join(self.gem_libdir, 'barcodes', '*.csv')]
end

.barcode_path(string) ⇒ Object

return path for barcode file given a string



24
25
26
# File 'lib/basil/barcodes.rb', line 24

def self.barcode_path(string)
  self.barcode_files.reject { |x| File.basename(x, File.extname(x)) != string }.first rescue nil
end

.barcodesObject



14
15
16
# File 'lib/basil/barcodes.rb', line 14

def self.barcodes
  self.barcode_files.map { |x| File.basename(x, File.extname(x)) }
end

.gem_libdirObject

return a directory with the project libraries



5
6
7
# File 'lib/basil/barcodes.rb', line 5

def self.gem_libdir
  File.dirname(__FILE__)
end

.has_barcode?(string) ⇒ Boolean

returns true if string matches a file in the barcodes directory

Returns:

  • (Boolean)


19
20
21
# File 'lib/basil/barcodes.rb', line 19

def self.has_barcode?(string)
  self.barcodes.include? File.basename(string, File.extname(string))
end