Class: Barby::Bookland
- Defined in:
- lib/barby/barcode/bookland.rb
Overview
Bookland barcodes are EAN-13 barcodes with number system 978/979 (hence “Bookland”). The data they encode is an ISBN with its check digit removed. This is a convenience class that takes an ISBN number instead of “pure” EAN-13 data.
#These are all the same:
= Bookland.new('978-0-306-40615-7')
= Bookland.new('978-0-306-40615')
= Bookland.new('0-306-40615-7')
= Bookland.new('0-306-40615')
If a prefix is not given, a default of 978 is used.
Defined Under Namespace
Classes: ISBN
Constant Summary
Constants inherited from EAN13
EAN13::CENTER, EAN13::FORMAT, EAN13::LEFT_ENCODINGS_EVEN, EAN13::LEFT_ENCODINGS_ODD, EAN13::LEFT_PARITY_MAPS, EAN13::RIGHT_ENCODINGS, EAN13::START, EAN13::STOP
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(isbn) ⇒ Bookland
constructor
isbn should be an ISBN number string, with or without an EAN prefix and an ISBN checksum non-number formatting like hyphens or spaces are ignored.
-
#isbn ⇒ Object
An instance of ISBN.
- #isbn=(isbn) ⇒ Object
Methods inherited from EAN13
#center_encoding, #characters, #checksum, #checksum_encoding, #data_with_checksum, #encoding, #left_encoding, #left_encodings, #left_numbers, #left_parity_map, #numbers, #numbers_with_checksum, #odd_and_even_numbers, #right_encoding, #right_encodings, #right_numbers, #start_encoding, #stop_encoding, #to_s, #upc?, #valid?, #weighted_sum
Methods inherited from Barcode
#encoding, #method_missing, #outputter_class_for, #outputter_for, outputters, register_outputter, #to_s, #two_dimensional?, #valid?
Constructor Details
#initialize(isbn) ⇒ Bookland
isbn should be an ISBN number string, with or without an EAN prefix and an ISBN checksum non-number formatting like hyphens or spaces are ignored
If a prefix is not given, a default of 978 is used.
24 25 26 27 |
# File 'lib/barby/barcode/bookland.rb', line 24 def initialize(isbn) self.isbn = isbn raise ArgumentError, 'data not valid' unless valid? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Barby::Barcode
Instance Method Details
#data ⇒ Object
29 30 31 |
# File 'lib/barby/barcode/bookland.rb', line 29 def data isbn.isbn end |
#isbn ⇒ Object
An instance of ISBN
38 39 40 |
# File 'lib/barby/barcode/bookland.rb', line 38 def isbn @isbn end |