Class: Lobbyliste::Factories::AddressFactory
- Defined in:
- lib/lobbyliste/factories/address_factory.rb
Overview
This class is used to build an address from raw data Since it is to hard to separate the na,e and address data without markup, we use the html data to accomplish that
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#fax ⇒ Object
readonly
Returns the value of attribute fax.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#postcode ⇒ Object
readonly
Returns the value of attribute postcode.
-
#tel ⇒ Object
readonly
Returns the value of attribute tel.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(name, raw_data, type = :primary) ⇒ AddressFactory
constructor
A new instance of AddressFactory.
- #parse ⇒ Object
Constructor Details
#initialize(name, raw_data, type = :primary) ⇒ AddressFactory
Returns a new instance of AddressFactory.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 27 def initialize(name,raw_data,type=:primary) @name = name @raw_data = raw_data @address = [] @tel = nil @fax = nil @website = nil @email = nil @country = "Deutschland" @postcode = nil @city = nil @type=type parse end |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def city @city end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def country @country end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def email @email end |
#fax ⇒ Object (readonly)
Returns the value of attribute fax.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def fax @fax end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def name @name end |
#postcode ⇒ Object (readonly)
Returns the value of attribute postcode.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def postcode @postcode end |
#tel ⇒ Object (readonly)
Returns the value of attribute tel.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def tel @tel end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def type @type end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
25 26 27 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 25 def website @website end |
Class Method Details
.build(name, raw_data, type = :primary) ⇒ Lobbyliste::Address
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 9 def self.build(name,raw_data, type=:primary) factory = new(name,raw_data,type) ::Lobbyliste::Address.new( factory.name, factory.address, factory.postcode, factory.city, factory.country, factory.tel, factory.fax, factory.website, factory.email, factory.type ) end |
Instance Method Details
#address ⇒ Object
58 59 60 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 58 def address @address.join(", ") end |
#parse ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lobbyliste/factories/address_factory.rb', line 44 def parse @raw_data.each_with_index do |line,i| case label(line,i) when :addr then @address << line when :tel then extract_tel_fax(line) when :postcode then extract_postcode_city(line) when :email then extract_email(line) when :website then extract_website(line) when :country then @country = line else next end end end |