class UKPostcode::InvalidPostcode

An InvalidPostcode is returned by UKPostcode.parse when it is unable to parse the supplied postcode. As it returns the input verbatim via to_s, it's possible to do UKPostcode.parse(s).to_s and get either a normalised postcode (if possible) or the original user input.

The sub-fields of the postcode (outcode, area, etc.) are all nil.

Public Class Methods

new(input) click to toggle source
# File lib/uk_postcode/invalid_postcode.rb, line 17
def initialize(input)
  @input = input
end
parse(str) click to toggle source
# File lib/uk_postcode/invalid_postcode.rb, line 13
def self.parse(str)
  new(str)
end

Public Instance Methods

full?() click to toggle source
# File lib/uk_postcode/invalid_postcode.rb, line 28
def full?
  false
end
to_s() click to toggle source

Returns the literal string supplied at initialisation. This may be helpful when returning erroneous input to the user.

# File lib/uk_postcode/invalid_postcode.rb, line 24
def to_s
  @input
end
valid?() click to toggle source
# File lib/uk_postcode/invalid_postcode.rb, line 32
def valid?
  false
end