Class: Motion::HTML::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/project/motion-html.rb

Instance Method Summary collapse

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