Module: Sawzall

Defined in:
lib/sawzall.rb,
lib/sawzall/version.rb

Defined Under Namespace

Classes: Document, Element

Constant Summary collapse

VERSION =
"0.1.0.pre2"

Class Method Summary collapse

Class Method Details

.parse_document(html) ⇒ Sawzall::Document

Parses the given string as a complete HTML document

Examples:

html = <<~HTML
  <!doctype html>
  <html>
    <head>
      <title>Page Title</title>
    </head>
    <body>
      <h1>Heading</h1>
    </body>
  </html>
HTML

Sawzall
  .parse_document(html)
  .select("head title")
  .first
  .text #=> "Page Title"

Parameters:

  • html (String)

Returns:



# File 'lib/sawzall.rb', line 20

.parse_fragment(html) ⇒ Sawzall::Document

Parses the given string as an HTML fragment

Examples:

Sawzall
  .parse_fragment("<h1 id='title'>Page Title</h1>")
  .select("h1")
  .first
  .attr("id") #=> "title"

Parameters:

  • html (String)

Returns:



# File 'lib/sawzall.rb', line 7