Class: WebInspector::Inspector
- Inherits:
-
Object
- Object
- WebInspector::Inspector
- Defined in:
- lib/web_inspector/inspector.rb
Instance Method Summary collapse
- #description ⇒ Object
- #images ⇒ Object
-
#initialize(page) ⇒ Inspector
constructor
A new instance of Inspector.
- #links ⇒ Object
- #meta ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(page) ⇒ Inspector
Returns a new instance of Inspector.
6 7 8 9 |
# File 'lib/web_inspector/inspector.rb', line 6 def initialize(page) @page = page @meta = WebInspector::Meta.new(page). end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/web_inspector/inspector.rb', line 15 def description @meta['description'] || snippet end |
#images ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/web_inspector/inspector.rb', line 31 def images images = [] @page.css("img").each do |img| images.push((img[:src].to_s.start_with? @url.to_s) ? img[:src] : URI.join(url, img[:src]).to_s) if (img and img[:src]) end return images end |
#links ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/web_inspector/inspector.rb', line 23 def links links = [] @page.css("a").each do |a| links.push((a[:href].to_s.start_with? @url.to_s) ? a[:href] : URI.join(@url, a[:href]).to_s) if (a and a[:href]) end return links end |
#meta ⇒ Object
19 20 21 |
# File 'lib/web_inspector/inspector.rb', line 19 def @meta end |
#title ⇒ Object
11 12 13 |
# File 'lib/web_inspector/inspector.rb', line 11 def title @page.css('title').inner_text.strip rescue nil end |