Class: MyRepresentatives::ACT::WebShow
- Inherits:
-
Object
- Object
- MyRepresentatives::ACT::WebShow
- Defined in:
- lib/my_representatives/act/web_show.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #image_url ⇒ Object
-
#initialize(url) ⇒ WebShow
constructor
A new instance of WebShow.
Constructor Details
#initialize(url) ⇒ WebShow
Returns a new instance of WebShow.
7 8 9 10 11 12 13 |
# File 'lib/my_representatives/act/web_show.rb', line 7 def initialize(url) @logger = Logger.new(STDOUT) raise MyRepresentatives::InvalidURLError unless url && url.is_a?(String) @url = url fetch_document raise MyRepresentatives::NokogiriDocumentPropertiesError unless test_document_for_validity end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
5 6 7 |
# File 'lib/my_representatives/act/web_show.rb', line 5 def document @document end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/my_representatives/act/web_show.rb', line 5 def logger @logger end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/my_representatives/act/web_show.rb', line 5 def url @url end |
Instance Method Details
#image_url ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/my_representatives/act/web_show.rb', line 15 def image_url begin @document.css("div.section").css("img")[0].attr('src') rescue NoMethodError nil end end |