Class: Nibbler

Inherits:
Object
  • Object
show all
Extended by:
NibblerMethods
Defined in:
lib/nibbler.rb

Overview

An HTML/XML scraper

Direct Known Subclasses

Article, BlogScraper

Defined Under Namespace

Classes: JsonDocument

Instance Method Summary collapse

Methods included from NibblerMethods

element, elements, extended, parse, rules

Constructor Details

#initialize(doc) ⇒ Nibbler

Parse data with Nokogiri unless it’s already an acceptable document



111
112
113
114
115
116
117
# File 'lib/nibbler.rb', line 111

def initialize(doc)
  unless doc.respond_to?(:at) and doc.respond_to?(:search)
    require 'nokogiri' unless defined? ::Nokogiri
    doc = Nokogiri doc
  end
  super(doc)
end