Class: MyRepresentatives::ACT::WebIndexRow
- Inherits:
-
Object
- Object
- MyRepresentatives::ACT::WebIndexRow
- Defined in:
- lib/my_representatives/act/web_index_row.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
Instance Method Summary collapse
- #address ⇒ Object
- #electorate_name ⇒ Object
- #email ⇒ Object
- #first_name ⇒ Object
- #homepage_url ⇒ Object
-
#initialize(document) ⇒ WebIndexRow
constructor
A new instance of WebIndexRow.
- #last_name ⇒ Object
- #party_name ⇒ Object
- #phone ⇒ Object
Constructor Details
#initialize(document) ⇒ WebIndexRow
Returns a new instance of WebIndexRow.
6 7 8 9 10 |
# File 'lib/my_representatives/act/web_index_row.rb', line 6 def initialize(document) raise MyRepresentatives::NokogiriDocumentExpectedError unless document && document.is_a?(Nokogiri::XML::Element) @document = document raise MyRepresentatives::NokogiriDocumentPropertiesError unless test_document_for_validity end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
4 5 6 |
# File 'lib/my_representatives/act/web_index_row.rb', line 4 def document @document end |
Instance Method Details
#address ⇒ Object
61 62 63 |
# File 'lib/my_representatives/act/web_index_row.rb', line 61 def address nil end |
#electorate_name ⇒ Object
27 28 29 30 31 32 |
# File 'lib/my_representatives/act/web_index_row.rb', line 27 def electorate_name begin @document.css("td")[2].text rescue end end |
#email ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/my_representatives/act/web_index_row.rb', line 51 def email begin text = @document.css("td")[4].text regex = /^(.+?@.+?.gov.au)/ regex.match(text)[1].strip rescue nil end end |
#first_name ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/my_representatives/act/web_index_row.rb', line 12 def first_name begin @document.css("a")[0].text.split(",")[1] rescue nil end end |
#homepage_url ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/my_representatives/act/web_index_row.rb', line 65 def homepage_url begin @document.css("a")[0].attr("href") rescue nil end end |
#last_name ⇒ Object
20 21 22 23 24 25 |
# File 'lib/my_representatives/act/web_index_row.rb', line 20 def last_name begin @document.css("a")[0].text.split(",")[0] rescue end end |
#party_name ⇒ Object
34 35 36 37 38 39 |
# File 'lib/my_representatives/act/web_index_row.rb', line 34 def party_name begin @document.css("td")[3].text rescue end end |
#phone ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/my_representatives/act/web_index_row.rb', line 41 def phone begin text = @document.css("td")[4].text regex = /Ph:(.+?)$/ regex.match(text)[1].strip rescue nil end end |