Class: Imb::Barcode
- Inherits:
-
Object
- Object
- Imb::Barcode
- Includes:
- Memoizer
- Defined in:
- lib/USPS-intelligent-barcode/barcode.rb
Overview
This class represents a barcode.
Instance Attribute Summary collapse
- #barcode_id ⇒ BarcodeId readonly
- #mailer_id ⇒ MailerId readonly
- #routing_code ⇒ RoutingCode readonly
- #serial_number ⇒ SerialNumber readonly
- #service_type ⇒ ServiceType readonly
Instance Method Summary collapse
-
#barcode_letters ⇒ String
Return a string to print using one of the USPS Intelligent Mail Barcode fonts.
-
#initialize(barcode_id, service_type, mailer_id, serial_number, routing_code) ⇒ Barcode
constructor
Create a new barcode.
Constructor Details
#initialize(barcode_id, service_type, mailer_id, serial_number, routing_code) ⇒ Barcode
Create a new barcode
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 44 def initialize(, service_type, mailer_id, serial_number, routing_code) @barcode_id = BarcodeId.coerce() @service_type = ServiceType.coerce(service_type) @mailer_id = MailerId.coerce(mailer_id) @serial_number = SerialNumber.coerce(serial_number) @routing_code = RoutingCode.coerce(routing_code) validate_components end |
Instance Attribute Details
#barcode_id ⇒ BarcodeId (readonly)
15 16 17 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 15 def @barcode_id end |
#mailer_id ⇒ MailerId (readonly)
21 22 23 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 21 def mailer_id @mailer_id end |
#routing_code ⇒ RoutingCode (readonly)
27 28 29 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 27 def routing_code @routing_code end |
#serial_number ⇒ SerialNumber (readonly)
24 25 26 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 24 def serial_number @serial_number end |
#service_type ⇒ ServiceType (readonly)
18 19 20 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 18 def service_type @service_type end |
Instance Method Details
#barcode_letters ⇒ String
Return a string to print using one of the USPS Intelligent Mail Barcode fonts. Each character of the string will be one of:
-
‘T’ for a tracking mark (neither ascender nor descender)
-
‘A’ for an ascender mark
-
‘D’ for a descender mark
-
‘F’ for a full mark (both ascender and descender)
65 66 67 |
# File 'lib/USPS-intelligent-barcode/barcode.rb', line 65 def symbols.map(&:letter).join end |