Class: MyRepresentatives::ACT::WebShow

Inherits:
Object
  • Object
show all
Defined in:
lib/my_representatives/act/web_show.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#documentObject

Returns the value of attribute document.



5
6
7
# File 'lib/my_representatives/act/web_show.rb', line 5

def document
  @document
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/my_representatives/act/web_show.rb', line 5

def logger
  @logger
end

#urlObject

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_urlObject



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