Class: OLE_QA::Framework::Bib_Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/data_factory/bib_factory.rb

Overview

Manufacture strings for bibliographic record testing

Class Method Summary collapse

Class Method Details

.barcodeObject

Return a random string of between 12 and 18 numbers to be used as a barcode.



19
20
21
# File 'lib/data_factory/bib_factory.rb', line 19

def self.barcode
  (0..(11..17).to_a.sample).map{(0..9).to_a.sample}.join
end

.call_number(format = "LOC") ⇒ Object

Return a random (non-validated) call number in the specified format.



24
25
26
27
28
29
30
31
32
33
# File 'lib/data_factory/bib_factory.rb', line 24

def self.call_number(format = "LOC")
  call_num = Array.new
  # TODO - Use case...when once other formats are added.
  # LOC Format Call Number
  call_num << (0..(0..1).to_a.sample).map{('A'..'Z').to_a.sample}.join
  call_num << (0..(1..3).to_a.sample).map{(1..9).to_a.sample}.join << " "
  call_num << "." <<  ('A'..'Z').to_a.sample
  call_num << (0..(1..2).to_a.sample).map{(1..9).to_a.sample}.join
  call_num.join
end