Sha256: a4c4358756eb1aab0c51c63c4c59f0670731a4c64f8a25aa9927034a5aaae0df
Contents?: true
Size: 958 Bytes
Versions: 21
Compression:
Stored size: 958 Bytes
Contents
require "hpricot" module Integrity class Notifier module Test # Thanks Harry! http://gist.github.com/39960 class HpricotMatcher def initialize(html) @doc = Hpricot(html) end # elements('h1') returns a Hpricot::Elements object with all h1-tags. def elements(selector) @doc.search(selector) end # element('h1') returns Hpricot::Elem with first h1-tag, or nil if # none exist. def element(selector) @doc.at(selector) end # tags('h1') returns the inner HTML of all matched elements mathed. def tags(selector) e = elements(selector) e.map {|x| x.inner_html} end # tag('h1') returns the inner HTML of the first mached element, or # nil if none matched. def tag(selector) e = element(selector) e && e.inner_html end end end end end
Version data entries
21 entries across 21 versions & 6 rubygems