Class: GoogleAlerts::Email
- Inherits:
-
Object
- Object
- GoogleAlerts::Email
- Defined in:
- lib/google_alerts/email.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(html) ⇒ Email
constructor
A new instance of Email.
Constructor Details
#initialize(html) ⇒ Email
Returns a new instance of Email.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/google_alerts/email.rb', line 9 def initialize(html) @results = [] doc = Nokogiri::HTML(html) styled_links = doc.css('a').select{|l| l['style']} alert_links = styled_links.select{|l| l['style'].match(/color:\s?#?1111[cC][cC]/) } alert_links.each do |link| desc = link.parent.at_css('font') if source_link = desc.at_css('a') source = source_link.content end desc.css('a').each(&:remove) blurb = desc.content @results << GoogleAlerts::Result.new(link[:href], link.content, source, blurb) end end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
7 8 9 |
# File 'lib/google_alerts/email.rb', line 7 def results @results end |