Class: Lobbyliste::Address

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

Overview

This class represents addresses found in the lobbylist.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, address, postcode, city, country, tel, fax, website, email, type) ⇒ Address

Returns a new instance of Address.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/lobbyliste/address.rb', line 35

def initialize(name, address, postcode, city, country, tel, fax, website, email, type)
  @name = name
  @address = address
  @postcode = postcode
  @city = city
  @country = country
  @tel = tel
  @fax = fax
  @website = website
  @email = email
  @type=type
end

Instance Attribute Details

#addressString (readonly)

Returns Everything that is not part of the name or any other field.

Returns:

  • (String)

    Everything that is not part of the name or any other field



9
10
11
# File 'lib/lobbyliste/address.rb', line 9

def address
  @address
end

#cityString (readonly)

Returns City.

Returns:



15
16
17
# File 'lib/lobbyliste/address.rb', line 15

def city
  @city
end

#countryString (readonly)

Returns the country, default: “Germany”.

Returns:

  • (String)

    the country, default: “Germany”



18
19
20
# File 'lib/lobbyliste/address.rb', line 18

def country
  @country
end

#emailString (readonly)

Returns contact email address.

Returns:

  • (String)

    contact email address



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

def email
  @email
end

#faxString (readonly)

Returns the fax number if given (german numbers are automatically prefixed with +49).

Returns:

  • (String)

    the fax number if given (german numbers are automatically prefixed with +49)



24
25
26
# File 'lib/lobbyliste/address.rb', line 24

def fax
  @fax
end

#nameString (readonly)

Returns organisation name (the bold part).

Returns:

  • (String)

    organisation name (the bold part)



6
7
8
# File 'lib/lobbyliste/address.rb', line 6

def name
  @name
end

#postcodeString (readonly)

Returns Postcode.

Returns:



12
13
14
# File 'lib/lobbyliste/address.rb', line 12

def postcode
  @postcode
end

#telString (readonly)

Returns the telephone number if given (german numbers are automatically prefixed with +49).

Returns:

  • (String)

    the telephone number if given (german numbers are automatically prefixed with +49)



21
22
23
# File 'lib/lobbyliste/address.rb', line 21

def tel
  @tel
end

#typeSymbol (readonly)

Returns address type, :primary for 1. address, :secondary for all others.

Returns:

  • (Symbol)

    address type, :primary for 1. address, :secondary for all others



33
34
35
# File 'lib/lobbyliste/address.rb', line 33

def type
  @type
end

#websiteString (readonly)

Returns website url.

Returns:



27
28
29
# File 'lib/lobbyliste/address.rb', line 27

def website
  @website
end

Instance Method Details

#full_addressObject

Returns String pretty formated address of all existing address fields.

Returns:

  • String pretty formated address of all existing address fields



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/lobbyliste/address.rb', line 49

def full_address
  full_address = [
    @name,
    @address,
    [@postcode,@city].reject(&:nil?).join(" "),
    @country,
  ]

  full_address << "Tel: #{@tel}" if @tel
  full_address << "Fax: #{@fax}" if @fax
  full_address << "Email: #{@email}" if @email
  full_address << @website if @website
  full_address.reject(&:nil?).join("\n")
end

#to_json(*a) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/lobbyliste/address.rb', line 64

def to_json(*a)
  {
      name: name,
      address: address,
      postcode: postcode,
      city: city,
      country: country,
      tel: tel,
      fax: fax,
      email: email,
      website: website,
      type: type.to_s
  }.to_json(*a)
end