Sha256: 4eaa5179364747617ed7ce73442ab2ea6bd826c6d2b44e512a2b3be27cb0ca8e
Contents?: true
Size: 912 Bytes
Versions: 3
Compression:
Stored size: 912 Bytes
Contents
module XeroGateway class Address attr_accessor :address_type, :line_1, :line_2, :line_3, :line_4, :city, :region, :post_code, :country def initialize(params = {}) params = { :address_type => "DEFAULT" }.merge(params) params.each do |k,v| self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair self.send("#{k}=", v) end end def self.parse(string) address = Address.new string.split("\r\n").each_with_index do |line, index| address.instance_variable_set("@line_#{index+1}", line) end address end def ==(other) [:address_type, :line_1, :line_2, :line_3, :line_4, :city, :region, :post_code, :country].each do |field| return false if send(field) != other.send(field) end return true end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tlconnor-xero_gateway-1.0.1 | lib/xero_gateway/address.rb |
tlconnor-xero_gateway-1.0.2 | lib/xero_gateway/address.rb |
tlconnor-xero_gateway-1.0.3 | lib/xero_gateway/address.rb |