class RPath::Adapter
An RPath
adapter makes it possible to evaluate RPath
expressions on some type of graph. There are built-in adapters for Nokogiri
, REXML
, and the filesystem. To build an adapter for another graph type, inherit from {Adapter} and implement the abstract methods. @abstract
Public Instance Methods
Used to infer the adapter when {#RPath} is called without an explicit adapter. The first registered adapter whose {#adapts?} returns true
is chosen. The default implementation returns false
. @param [Object] graph @return [Boolean] @see RPath
@see RPath.use
# File lib/rpath/adapter.rb, line 17 def adapts?(graph) false end
Returns the vertices adjacent to the given vertex. @abstract @param [Object] vertex @return [Array]
# File lib/rpath/adapter.rb, line 42 def adjacent(vertex) raise NotImplementedError end
Returns the value of attribute name
of vertex
or nil
if no such attribute exists. @abstract @param [Object] vertex @param [String, Symbol] name @return [Object, nil]
# File lib/rpath/adapter.rb, line 52 def attribute(vertex, name) raise NotImplementedError end
Returns the content of vertex
or nil if no content exists. @abstract @param [Object] vertex @return [Object, nil]
# File lib/rpath/adapter.rb, line 60 def content(vertex) raise NotImplementedError end
Returns the name of the given vertex @abstract @param [Object] vertex @return [String]
# File lib/rpath/adapter.rb, line 34 def name(vertex) raise NotImplementedError end
Returns the root of the given graph, the vertex where evaluation begins. The default implementation returns the given graph. the given graph. @param [Object] graph @return [Object]
# File lib/rpath/adapter.rb, line 26 def root(graph) graph end