Class: Nokogiri::HTML5::DocumentFragment
- Inherits:
-
XML::DocumentFragment
- Object
- XML::DocumentFragment
- Nokogiri::HTML5::DocumentFragment
- Defined in:
- lib/wasmify/rails/shims/nokogiri.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #children ⇒ Object
- #css(selector) ⇒ Object
- #deconstruct ⇒ Object
- #dup ⇒ Object
-
#initialize(html_string) ⇒ DocumentFragment
constructor
A new instance of DocumentFragment.
- #to_html(options = {}) ⇒ Object
Constructor Details
#initialize(html_string) ⇒ DocumentFragment
Returns a new instance of DocumentFragment.
35 36 37 38 39 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 35 def initialize(html_string) @html_string = html_string @elements = [] @name = html_string.match(/<(\w+)/).then { next unless _1; _1[1] } end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
33 34 35 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 33 def elements @elements end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 33 def name @name end |
Instance Method Details
#children ⇒ Object
50 51 52 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 50 def children [] end |
#css(selector) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 41 def css(selector) # Return array of matching nodes # Must support selectors like: # - "a[href]" - anchor tags with href attribute # - "action-text-attachment" - elements by tag name # - Complex selectors for attachment galleries [] end |
#deconstruct ⇒ Object
67 68 69 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 67 def deconstruct children end |
#dup ⇒ Object
54 55 56 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 54 def dup self.class.new(@html_string) end |
#to_html(options = {}) ⇒ Object
58 59 60 61 |
# File 'lib/wasmify/rails/shims/nokogiri.rb', line 58 def to_html( = {}) # Must respect options[:save_with] if provided @html_string end |