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, 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

@returns [String]

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

Available since:

  • next


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

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

@returns [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:

  • next


28
29
30
# File 'lib/faker/default/barcode.rb', line 28

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

@returns [String]

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

Available since:

  • next


83
84
85
# File 'lib/faker/default/barcode.rb', line 83

def isbn
  generate_barcode('barcode.isbn')
end

.ismnObject

Returns a ISMN format barcode number with check digit

@returns [String]

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

Available since:

  • next


94
95
96
# File 'lib/faker/default/barcode.rb', line 94

def ismn
  generate_barcode('barcode.ismn')
end

.issnObject

Returns a ISSN format barcode number with check digit

@returns [String]

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

Available since:

  • next


105
106
107
# File 'lib/faker/default/barcode.rb', line 105

def issn
  generate_barcode('barcode.issn')
end

.upc_aObject

Returns a UPC_A format barcode number with check digit

@returns [String]

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

Available since:

  • next


39
40
41
# File 'lib/faker/default/barcode.rb', line 39

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

@returns [String]

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

Available since:

  • next


61
62
63
# File 'lib/faker/default/barcode.rb', line 61

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

@returns [String]

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

Available since:

  • next


50
51
52
# File 'lib/faker/default/barcode.rb', line 50

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

@returns [String]

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

Available since:

  • next


72
73
74
# File 'lib/faker/default/barcode.rb', line 72

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