Class: PeterMueller::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/peter-mueller/address.rb

Overview

A fictitious address. The address should look valid, but is not an existing address. The street might not even exist in the town. But, by accident, the address could exist.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAddress

Creates a new Address.



17
18
19
20
21
# File 'lib/peter-mueller/address.rb', line 17

def initialize
  (@zip, @phone_prefix, @town) = TOWNS.sample.split("\t")
  @street_name = STREETS.sample
  @street_number = rand(1..120).to_s + (rand(30)==15 ? ('a'..'e').to_a.sample : "")
end

Instance Attribute Details

#phone_prefixObject (readonly)

The landline phone prefix for the address. This can be used, when generating a Phonenumber which should fit with the address.



14
15
16
# File 'lib/peter-mueller/address.rb', line 14

def phone_prefix
  @phone_prefix
end

#street_nameObject (readonly)

Name of the town, the street and its numner.



10
11
12
# File 'lib/peter-mueller/address.rb', line 10

def street_name
  @street_name
end

#street_numberObject (readonly)

Name of the town, the street and its numner.



10
11
12
# File 'lib/peter-mueller/address.rb', line 10

def street_number
  @street_number
end

#townObject (readonly)

Name of the town, the street and its numner.



10
11
12
# File 'lib/peter-mueller/address.rb', line 10

def town
  @town
end

#zipObject (readonly)

The zip code (PLZ).



7
8
9
# File 'lib/peter-mueller/address.rb', line 7

def zip
  @zip
end

Instance Method Details

#streetObject

The streetname and the streetnumber in one string.



24
25
26
# File 'lib/peter-mueller/address.rb', line 24

def street
  "#{@street_name} #{@street_number}"
end

#to_sObject

The string representation of the address.



29
30
31
# File 'lib/peter-mueller/address.rb', line 29

def to_s
  "#{street}\n#{zip} #{town}"
end