Class: Hexp::Node::Domize
- Inherits:
-
Object
- Object
- Hexp::Node::Domize
- Defined in:
- lib/hexp/node/domize.rb
Overview
Turn nodes into DOM objects
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :include_doctype => true }.freeze
Instance Attribute Summary collapse
-
#dom ⇒ Nokogiri::HTML::Document
readonly
private
The resulting DOM Document.
Instance Method Summary collapse
-
#call ⇒ Nokogiri::HTML::Document
private
Turn the hexp into a DOM.
-
#initialize(hexp, options = {}) ⇒ Domize
constructor
private
Instanitiate a Domizer.
Constructor Details
#initialize(hexp, options = {}) ⇒ Domize
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instanitiate a Domizer
24 25 26 27 28 |
# File 'lib/hexp/node/domize.rb', line 24 def initialize(hexp, = {}) @dom = Hexp::DOM @raw = hexp @options = DEFAULT_OPTIONS.merge().freeze end |
Instance Attribute Details
#dom ⇒ Nokogiri::HTML::Document (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The resulting DOM Document
14 15 16 |
# File 'lib/hexp/node/domize.rb', line 14 def dom @dom end |
Instance Method Details
#call ⇒ Nokogiri::HTML::Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Turn the hexp into a DOM
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hexp/node/domize.rb', line 35 def call @doc = dom::Document.new if @options[:html5] @doc.children = dom::NodeSet.new(@doc, []) @doc.create_internal_subset(nil, nil, nil) end @root = domize(@raw) @doc << @root if @options[:include_doctype] @doc else @root end end |