Class: Deliveries::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/address.rb

Constant Summary collapse

COUNTRY_PHONE_PREFIXES =
{
  be: 32,
  fr: 33,
  es: 34,
  it: 39,
  gb: 44,
  de: 49,
  pt: 351
}.freeze
COUNTRY_TRUNK_PREFIXES =
{
  be: 0,
  fr: 0,
  es: nil,
  it: nil,
  gb: 0,
  de: 0,
  pt: nil
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Address

Returns a new instance of Address.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/deliveries/address.rb', line 24

def initialize(**attributes)
  self.name = attributes[:name]
  self.email = attributes[:email]
  self.phone = attributes[:phone]
  self.country = attributes[:country]
  self.state = attributes[:state]
  self.city = attributes[:city]
  self.street = attributes[:street]
  self.postcode = attributes[:postcode]
  self.address_id = attributes[:address_id]
end

Instance Attribute Details

#address_idObject

Returns the value of attribute address_id.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def address_id
  @address_id
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def city
  @city
end

#countryObject

Returns the value of attribute country.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def country
  @country
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def email
  @email
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def phone
  @phone
end

#postcodeObject

Returns the value of attribute postcode.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def postcode
  @postcode
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def state
  @state
end

#streetObject

Returns the value of attribute street.



3
4
5
# File 'lib/deliveries/address.rb', line 3

def street
  @street
end

Instance Method Details

#courierize(courier_id) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/deliveries/address.rb', line 36

def courierize(courier_id)
  courier_address = %(Deliveries::Couriers::#{courier_id.to_s.camelize}::Address).safe_constantize.new
  instance_variables.each do |iv|
    courier_address.instance_variable_set(iv, instance_variable_get(iv))
  end
  courier_address
end