Class: Lobbyliste::Factories::OrganisationFactory
- Defined in:
- lib/lobbyliste/factories/organisation_factory.rb
Overview
This class is used to build an organisation from raw data
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #additional_address ⇒ Object
- #address ⇒ Object
- #address_at_bt_br ⇒ Object
- #associated_organisations ⇒ Object
- #id ⇒ Object
-
#initialize(name, raw_data) ⇒ OrganisationFactory
constructor
A new instance of OrganisationFactory.
- #interests ⇒ Object
- #members ⇒ Object
- #people ⇒ Object
Constructor Details
#initialize(name, raw_data) ⇒ OrganisationFactory
Returns a new instance of OrganisationFactory.
27 28 29 30 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 27 def initialize(name,raw_data) @name = name @raw_data = raw_data end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 25 def name @name end |
Class Method Details
.build(name, raw_data, tags, abbreviations) ⇒ Lobbyliste::Organisation
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 8 def self.build(name, raw_data,,abbreviations) factory = new(name, raw_data) ::Lobbyliste::Organisation.new( factory.id, factory.name, factory.address, factory.additional_address, factory.address_at_bt_br, factory.people, factory.interests, factory.members, factory.associated_organisations, , abbreviations ) end |
Instance Method Details
#additional_address ⇒ Object
42 43 44 45 46 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 42 def additional_address data = read_section("W e i t e r e A d r e s s e") return nil if data[0] == "–" AddressFactory.build(name, data, :secondary) end |
#address ⇒ Object
37 38 39 40 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 37 def address data = read_section("N a m e u n d S i t z , 1 . A d r e s s e") AddressFactory.build(name, data, :primary) end |
#address_at_bt_br ⇒ Object
48 49 50 51 52 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 48 def address_at_bt_br data = read_section("A n s c h r i f t a m S i t z v o n B T u n d B R g") return nil if data[0] == "–" || data[0].match(/\(s\. Abschnitt/) AddressFactory.build(name, data, :secondary) end |
#associated_organisations ⇒ Object
89 90 91 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 89 def associated_organisations read_section("A n z a h l d e r a n g e s c h l o s s e n e n O r g a n i s a t i o n e n")[0].to_i || nil end |
#id ⇒ Object
32 33 34 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 32 def id @raw_data.first.to_i end |
#interests ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 62 def interests interest_lines = read_section("I n t e r e s s e n b e r e i c h").dup (0..interest_lines.count-1).each do |i| line = interest_lines[i] next_line = interest_lines[i+1] if line =~ /[-–]$/ && !(next_line.start_with?("und"," und", "oder", " oder")) line.gsub!(/[-–]$/,"") next_line_words = next_line.split(" ") line += next_line_words.slice!(0) next_line = next_line_words.join(" ") end interest_lines[i] = line interest_lines[i+1] = next_line end interest_lines.reject(&:blank?).join("\n") end |
#members ⇒ Object
85 86 87 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 85 def members read_section("M i t g l i e d e r z a h l")[0].to_i || nil end |
#people ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/lobbyliste/factories/organisation_factory.rb', line 54 def people data = read_section("V o r s t a n d u n d G e s c h ä f t s f ü h r u n g") data.concat read_section("V e r b a n d s v e r t r e t e r / - i n n e n") data.reject! {|line| ignored_person_line?(line)} data.map { |person| PersonFactory.build(person) }.uniq.reject(&:nil?) end |