class Indirizzo::Map

Attributes

regexp[RW]
The Map class provides a two-way mapping between postal abbreviations
and their fully written equivalents.

attr_accessor :partial

Public Class Methods

[](*items) click to toggle source
Calls superclass method
# File lib/indirizzo/constants.rb, line 11
def self.[] (*items)
  hash = super(*items)
  hash.build_match
  hash.keys.each {|k| hash[k.downcase] = hash.fetch(k)}
  hash.values.each {|v| hash[v.downcase] = v}
  hash.freeze
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/indirizzo/constants.rb, line 26
def [] (key)
  super(key.downcase)
end
build_match() click to toggle source
# File lib/indirizzo/constants.rb, line 18
def build_match
  @regexp = Regexp.new(
    '\b(' + [keys,values].flatten.join("|") + ')\b',
    Regexp::IGNORECASE)
end
key?(key) click to toggle source
Calls superclass method
# File lib/indirizzo/constants.rb, line 23
def key? (key)
  super(key.downcase)
end