ruby-avm-library/lib/avm/contact.rb

25 lines
456 B
Ruby
Raw Normal View History

2011-03-07 21:38:20 +00:00
module AVM
class Contact
FIELD_MAP = {
:zip => :postal_code,
:state => :state_province,
:province => :state_province
}
attr_accessor :primary
def initialize(info)
@info = Hash[info.collect { |key, value| [ FIELD_MAP[key] || key, value ] }]
@primary = false
end
def method_missing(key)
@info[FIELD_MAP[key] || key]
end
def <=>(other)
self.name <=> other.name
end
end
end