Class: RPath::Adapters::Nokogiri

Inherits:
RPath::Adapter show all
Defined in:
lib/rpath/adapters/nokogiri.rb

Instance Method Summary collapse

Methods inherited from RPath::Adapter

#root

Instance Method Details

#adapts?(graph) ⇒ Boolean

Returns true iff graph is a Nokogiri::XML::Node.

Parameters:

  • graph (Object)

Returns:

  • (Boolean)


11
12
13
# File 'lib/rpath/adapters/nokogiri.rb', line 11

def adapts?(graph)
  graph.is_a? ::Nokogiri::XML::Node
end

#adjacent(vertex) ⇒ Array<Nokogiri::XML::Node>

Returns the child elements of the given node

Parameters:

Returns:



25
26
27
# File 'lib/rpath/adapters/nokogiri.rb', line 25

def adjacent(vertex)
  vertex.children.to_a
end

#attribute(vertex, name) ⇒ String?

Returns the value of the named attribute on the given node.

Parameters:

Returns:

  • (String, nil)


33
34
35
# File 'lib/rpath/adapters/nokogiri.rb', line 33

def attribute(vertex, name)
  vertex[name.to_s]
end

#content(vertex) ⇒ String?

Returns the text content of the given node.

Parameters:

Returns:

  • (String, nil)


40
41
42
# File 'lib/rpath/adapters/nokogiri.rb', line 40

def content(vertex)
  vertex.text
end

#name(vertex) ⇒ String

Returns the name of the given node

Parameters:

Returns:

  • (String)


18
19
20
# File 'lib/rpath/adapters/nokogiri.rb', line 18

def name(vertex)
  vertex.name
end