class UKPostcode::GiroPostcode
GiroPostcode
models the single, peculiar GIR 0AA postcode originally used by Girobank.
area, district, sector, and unit all return nil, because this postcode does not meaningfully possess these distinctions.
Constants
- PATTERN
Public Class Methods
new()
click to toggle source
# File lib/uk_postcode/giro_postcode.rb, line 24 def initialize end
parse(str)
click to toggle source
Returns an instance of GiroPostcode
if str represents GIR 0AA, and nil otherwise.
# File lib/uk_postcode/giro_postcode.rb, line 20 def self.parse(str) PATTERN.match(str.strip) ? instance : nil end
Public Instance Methods
country()
click to toggle source
GIR 0AA is in England. (In Bootle, in fact.)
# File lib/uk_postcode/giro_postcode.rb, line 59 def country :england end
full?()
click to toggle source
GIR 0AA is always full.
# File lib/uk_postcode/giro_postcode.rb, line 53 def full? true end
incode()
click to toggle source
The right-hand part of the postcode, always “0AA”.
# File lib/uk_postcode/giro_postcode.rb, line 35 def incode "0AA" end
outcode()
click to toggle source
The left-hand part of the postcode, always “GIR”.
# File lib/uk_postcode/giro_postcode.rb, line 29 def outcode "GIR" end
to_s()
click to toggle source
The canonical string representation of the postcode, i.e. “GIR 0AA”.
# File lib/uk_postcode/giro_postcode.rb, line 41 def to_s "GIR 0AA" end
valid?()
click to toggle source
GIR 0AA is always valid.
# File lib/uk_postcode/giro_postcode.rb, line 47 def valid? true end