class AudioBookCreator::WebPage
Attributes
body[RW]
url[RW]
Public Class Methods
map_urls(url)
click to toggle source
# File lib/audio_book_creator/web_page.rb, line 35 def self.map_urls(url) url.map { |o| uri(o) } end
new(url, body)
click to toggle source
attr_accessor :etag
# File lib/audio_book_creator/web_page.rb, line 10 def initialize(url, body) @url = url @body = body end
Private Class Methods
uri(url, alt = nil)
click to toggle source
raises URI::Error (BadURIError)
# File lib/audio_book_creator/web_page.rb, line 42 def self.uri(url, alt = nil) url = URI.parse(url) unless url.is_a?(URI) url += alt if alt url.fragment = nil # remove #x part of url url end
Public Instance Methods
==(other)
click to toggle source
# File lib/audio_book_creator/web_page.rb, line 29 def ==(other) other.kind_of?(WebPage) && other.url.eql?(url) end
Also aliased as: eql?
css(path)
click to toggle source
def single_css(path) ; css(path).first ; end
# File lib/audio_book_creator/web_page.rb, line 16 def css(path) dom.css(path).map {|n| n.text } end
links(path)
click to toggle source
# File lib/audio_book_creator/web_page.rb, line 20 def links(path) dom.css(path).map { |a| self.class.uri(url, a["href"]) } end
Private Instance Methods
dom()
click to toggle source
# File lib/audio_book_creator/web_page.rb, line 24 def dom @dom ||= Nokogiri::HTML(body) end