Class: Lobbyliste::Address
Overview
This class represents addresses found in the lobbylist.
Instance Attribute Summary collapse
-
#address ⇒ String
readonly
Everything that is not part of the name or any other field.
-
#city ⇒ String
readonly
City.
-
#country ⇒ String
readonly
The country, default: “Germany”.
-
#email ⇒ String
readonly
Contact email address.
-
#fax ⇒ String
readonly
The fax number if given (german numbers are automatically prefixed with +49).
-
#name ⇒ String
readonly
Organisation name (the bold part).
-
#postcode ⇒ String
readonly
Postcode.
-
#tel ⇒ String
readonly
The telephone number if given (german numbers are automatically prefixed with +49).
-
#type ⇒ Symbol
readonly
Address type, :primary for 1.
-
#website ⇒ String
readonly
Website url.
Instance Method Summary collapse
-
#full_address ⇒ Object
String pretty formated address of all existing address fields.
-
#initialize(name, address, postcode, city, country, tel, fax, website, email, type) ⇒ Address
constructor
A new instance of Address.
- #to_json(*a) ⇒ Object
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
#address ⇒ String (readonly)
Returns 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 |
#city ⇒ String (readonly)
Returns City.
15 16 17 |
# File 'lib/lobbyliste/address.rb', line 15 def city @city end |
#country ⇒ String (readonly)
Returns the country, default: “Germany”.
18 19 20 |
# File 'lib/lobbyliste/address.rb', line 18 def country @country end |
#email ⇒ String (readonly)
Returns contact email address.
30 31 32 |
# File 'lib/lobbyliste/address.rb', line 30 def email @email end |
#fax ⇒ String (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns organisation name (the bold part).
6 7 8 |
# File 'lib/lobbyliste/address.rb', line 6 def name @name end |
#postcode ⇒ String (readonly)
Returns Postcode.
12 13 14 |
# File 'lib/lobbyliste/address.rb', line 12 def postcode @postcode end |
#tel ⇒ String (readonly)
Returns 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 |
#type ⇒ Symbol (readonly)
Returns address type, :primary for 1. address, :secondary for all others.
33 34 35 |
# File 'lib/lobbyliste/address.rb', line 33 def type @type end |
#website ⇒ String (readonly)
Returns website url.
27 28 29 |
# File 'lib/lobbyliste/address.rb', line 27 def website @website end |
Instance Method Details
#full_address ⇒ Object
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 |