class NumberPlate::SG::Validator

Public Class Methods

new() click to toggle source
# File lib/number_plate/sg/validator.rb, line 9
def initialize
  @country = "SG"
end

Public Instance Methods

is_valid?(registration_number) click to toggle source
# File lib/number_plate/sg/validator.rb, line 13
def is_valid?(registration_number)
  super &&
    valid_length? &&
    valid_pattern? &&
    valid_checksum?
end
valid_checksum?() click to toggle source
# File lib/number_plate/sg/validator.rb, line 28
def valid_checksum?
  checksum == @license[-1]
end
valid_length?() click to toggle source
# File lib/number_plate/sg/validator.rb, line 20
def valid_length?
  @license.length <= 8 && @license.length >= 4
end
valid_pattern?() click to toggle source
# File lib/number_plate/sg/validator.rb, line 24
def valid_pattern?
  0  == (/^[A-Z]{1,3}[1-9]{1}\d{0,3}[A-Z]$/ =~ @license)
end