Class: Faker::Barcode

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/barcode.rb

Constant Summary

Constants inherited from Base

Faker::Base::LLetters, Faker::Base::Letters, Faker::Base::NOT_GIVEN, Faker::Base::Numbers, Faker::Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.ean(length = 8) ⇒ Object

Returns a EAN 8 or 13 digit format barcode number with check digit

@return [String]

@example
   Faker::Barcode.ean      => "85657526"
   Faker::Barcode.ean(8)   => "30152700"
   Faker::Barcode.ean(13)  => "2115190480285"

Available since:

  • 2.14.0



16
17
18
# File 'lib/faker/default/barcode.rb', line 16

def ean(length = 8)
  generate_barcode("barcode.ean_#{Integer(length)}")
end

.ean_with_composite_symbology(length = 8) ⇒ Object

Returns a EAN 8 or 13 digit format barcode number with composite string attached with check digit

@return [String]

@example
   Faker::Barcode.ean_with_composite_sumbology      => "41007624|JHOC6649"
   Faker::Barcode.ean_with_composite_sumbology(8)   => "38357961|XUYJ3266"
   Faker::Barcode.ean_with_composite_sumbology(13)  => "9530722443911|CKHWQHID"

Available since:

  • 2.14.0



30
31
32
# File 'lib/faker/default/barcode.rb', line 30

def ean_with_composite_symbology(length = 8)
  "#{ean(length)}|#{bothify(parse('barcode.composite_symbol'))}"
end

.isbnObject

Returns a ISBN format barcode number with check digit

@return [String]

@example
   Faker::Barcode.isbn      => "9798363807732"

Available since:

  • 2.14.0



90
91
92
# File 'lib/faker/default/barcode.rb', line 90

def isbn
  generate_barcode('barcode.isbn')
end

.ismnObject

Returns a ISMN format barcode number with check digit

@return [String]

@example
   Faker::Barcode.ismn      => "9790527672897"

Available since:

  • 2.14.0



102
103
104
# File 'lib/faker/default/barcode.rb', line 102

def ismn
  generate_barcode('barcode.ismn')
end

.issnObject

Returns a ISSN format barcode number with check digit

@return [String]

@example
   Faker::Barcode.issn      => "9775541703338"

Available since:

  • 2.14.0



114
115
116
# File 'lib/faker/default/barcode.rb', line 114

def issn
  generate_barcode('barcode.issn')
end

.upc_aObject

Returns a UPC_A format barcode number with check digit

@return [String]

@example
   Faker::Barcode.upc_a      => "766807541831"

Available since:

  • 2.14.0



42
43
44
# File 'lib/faker/default/barcode.rb', line 42

def upc_a
  generate_barcode('barcode.upc_a')
end

.upc_a_with_composite_symbologyObject

Returns a UPC_A format barcode number with composite string attached with check digit

@return [String]

@example
   Faker::Barcode.upc_a_with_composite_symbology      => "790670155765|JOVG6208"

Available since:

  • 2.14.0



66
67
68
# File 'lib/faker/default/barcode.rb', line 66

def upc_a_with_composite_symbology
  "#{upc_a}|#{bothify(parse('barcode.composite_symbol'))}"
end

.upc_eObject

Returns a UPC_E format barcode number with check digit

@return [String]

@example
   Faker::Barcode.upc_e      => "03746820"

Available since:

  • 2.14.0



54
55
56
# File 'lib/faker/default/barcode.rb', line 54

def upc_e
  generate_barcode('barcode.upc_e')
end

.upc_e_with_composite_symbologyObject

Returns a UPC_E format barcode number with composite string attached with check digit

@return [String]

@example
   Faker::Barcode.upc_e_with_composite_symbology      => "05149247|BKZX9722"

Available since:

  • 2.14.0



78
79
80
# File 'lib/faker/default/barcode.rb', line 78

def upc_e_with_composite_symbology
  "#{upc_e}|#{bothify(parse('barcode.composite_symbol'))}"
end