Class: Motion::HTML::Doc
- Inherits:
-
Object
- Object
- Motion::HTML::Doc
- Defined in:
- lib/project/motion-html.rb
Instance Method Summary collapse
- #all(q) ⇒ Object
- #first(q) ⇒ Object (also: #find)
-
#initialize(html) ⇒ Doc
constructor
A new instance of Doc.
Constructor Details
#initialize(html) ⇒ Doc
Returns a new instance of Doc.
8 9 10 |
# File 'lib/project/motion-html.rb', line 8 def initialize(html) @doc = HTMLDocument.documentWithString(html) end |
Instance Method Details
#all(q) ⇒ Object
12 13 14 15 |
# File 'lib/project/motion-html.rb', line 12 def all(q) nodes = @doc.querySelectorAll(q) nodes.map {|node| Element.new(node) } end |
#first(q) ⇒ Object Also known as: find
17 18 19 |
# File 'lib/project/motion-html.rb', line 17 def first(q) all(q).first end |