class Jan::Code
Attributes
body[R]
check_digit[R]
Public Class Methods
new(code)
click to toggle source
@param code [String]
Calls superclass method
# File lib/jan/code.rb, line 7 def initialize(code) @body = Jan::CodeBody.new(code[0..-2]) @check_digit = Jan::CheckDigit.new(code[-1]) super(code) end
Public Instance Methods
instore_code?()
click to toggle source
@return [boolean] @deprecated Use `instore_marking?` instead.
# File lib/jan/code.rb, line 22 def instore_code? instore_marking? end
instore_marking?()
click to toggle source
@return [boolean]
# File lib/jan/code.rb, line 27 def instore_marking? @body.start_with?('2') end
source_marking?()
click to toggle source
@return [boolean]
# File lib/jan/code.rb, line 32 def source_marking? !instore_marking? end
valid?()
click to toggle source
@return [boolean]
# File lib/jan/code.rb, line 16 def valid? @body.valid? && @check_digit.valid? && @body.calculate_check_digit == @check_digit end