Class: Jan::Code
- Inherits:
-
String
- Object
- String
- Jan::Code
- Defined in:
- lib/jan/code.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#check_digit ⇒ Object
readonly
Returns the value of attribute check_digit.
Instance Method Summary collapse
-
#initialize(code) ⇒ Code
constructor
A new instance of Code.
-
#instore_code? ⇒ boolean
deprecated
Deprecated.
Use ‘instore_marking?` instead.
- #instore_marking? ⇒ boolean
- #source_marking? ⇒ boolean
- #valid? ⇒ boolean
Constructor Details
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
13 14 15 |
# File 'lib/jan/code.rb', line 13 def body @body end |
#check_digit ⇒ Object (readonly)
Returns the value of attribute check_digit.
13 14 15 |
# File 'lib/jan/code.rb', line 13 def check_digit @check_digit end |
Instance Method Details
#instore_code? ⇒ boolean
Deprecated.
Use ‘instore_marking?` instead.
22 23 24 |
# File 'lib/jan/code.rb', line 22 def instore_code? instore_marking? end |
#instore_marking? ⇒ boolean
27 28 29 |
# File 'lib/jan/code.rb', line 27 def instore_marking? @body.start_with?('2') end |
#source_marking? ⇒ boolean
32 33 34 |
# File 'lib/jan/code.rb', line 32 def source_marking? !instore_marking? end |
#valid? ⇒ boolean
16 17 18 |
# File 'lib/jan/code.rb', line 16 def valid? @body.valid? && @check_digit.valid? && @body.calculate_check_digit == @check_digit end |