Class: MechanizeContent::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/mechanize_content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Parser

Returns a new instance of Parser.



13
14
15
# File 'lib/mechanize_content.rb', line 13

def initialize(*args)
  @pages = *args.flatten.map{|url| Page.new(url)}
end

Instance Attribute Details

#pagesObject

Returns the value of attribute pages.



11
12
13
# File 'lib/mechanize_content.rb', line 11

def pages
  @pages
end

Instance Method Details

#best_imageObject



25
26
27
# File 'lib/mechanize_content.rb', line 25

def best_image
  @pages.map{|page| page.image}.compact.first
end

#best_image_iphoneObject



29
30
31
# File 'lib/mechanize_content.rb', line 29

def best_image_iphone
  @pages.map{|page| page.image_iphone}.compact.first
end

#best_textObject



21
22
23
# File 'lib/mechanize_content.rb', line 21

def best_text
  @pages.map{|page| page.text}.compact.first
end

#best_titleObject



17
18
19
# File 'lib/mechanize_content.rb', line 17

def best_title
  @pages.map{|page| page.title}.compact.first || @pages.first.url
end