Module: Foo::Address

Extended by:
Address
Included in:
Address
Defined in:
lib/foo/address.rb

Constant Summary collapse

ADDRESSES =
{
  travelodge: {
    uk_postcode: "E1 7EZ",
    town: "London",
    address_1: "20 Middlesex Street",
    phone:  "(871) 984 6534"
  },
  point_a: {
    uk_postcode: "N1 6BX",
    town: "London",
    address_1: "13-15 Folgate Street",
    address_2: "Spitalfields"
  }
}

Instance Method Summary collapse

Instance Method Details

#address_1(branch) ⇒ Object



30
31
32
# File 'lib/foo/address.rb', line 30

def address_1(branch)
  ADDRESSES[branch.to_sym][:address_1]
end

#address_2(branch) ⇒ Object



34
35
36
# File 'lib/foo/address.rb', line 34

def address_2(branch)
  ADDRESSES[branch.to_sym][:address_2]
end

#full_address(branch) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/foo/address.rb', line 42

def full_address(branch)
  address = "#{ address_1(branch) }#{ ', ' + address_2(branch) if address_2(branch) }, #{ town(branch) } #{ uk_postcode(branch) }"
  if phone(branch) 
    address = "#{address}, #{phone(branch)}"
  end
  address
end

#full_address_as_array(branch) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/foo/address.rb', line 50

def full_address_as_array(branch)
  [
    address_1(branch),
    address_2(branch),
    town(branch),
    uk_postcode(branch),
    phone(branch)
  ].compact
end

#phone(branch) ⇒ Object



38
39
40
# File 'lib/foo/address.rb', line 38

def phone(branch)
  ADDRESSES[branch.to_sym][:phone]
end

#town(branch) ⇒ Object



26
27
28
# File 'lib/foo/address.rb', line 26

def town(branch)
  ADDRESSES[branch.to_sym][:town]
end

#uk_postcode(branch) ⇒ Object Also known as: zipcode



20
21
22
# File 'lib/foo/address.rb', line 20

def uk_postcode(branch)
  ADDRESSES[branch.to_sym][:uk_postcode] || ADDRESSES[branch.to_sym][:zipcode]
end