Class: RPath::Adapter Abstract
- Inherits:
-
Object
- Object
- RPath::Adapter
- Defined in:
- lib/rpath/adapter.rb
Overview
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.
Direct Known Subclasses
RPath::Adapters::Filesystem, RPath::Adapters::Nokogiri, RPath::Adapters::Oga, RPath::Adapters::REXML
Instance Method Summary collapse
-
#adapts?(graph) ⇒ Boolean
Used to infer the adapter when #RPath is called without an explicit adapter.
-
#adjacent(vertex) ⇒ Array
abstract
Returns the vertices adjacent to the given vertex.
-
#attribute(vertex, name) ⇒ Object?
abstract
Returns the value of attribute
name
ofvertex
ornil
if no such attribute exists. -
#content(vertex) ⇒ Object?
abstract
Returns the content of
vertex
or nil if no content exists. -
#name(vertex) ⇒ String
abstract
Returns the name of the given vertex.
-
#root(graph) ⇒ Object
Returns the root of the given graph, the vertex where evaluation begins.
Instance Method Details
#adapts?(graph) ⇒ Boolean
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
.
17 18 19 |
# File 'lib/rpath/adapter.rb', line 17 def adapts?(graph) false end |
#adjacent(vertex) ⇒ Array
Returns the vertices adjacent to the given vertex.
42 43 44 |
# File 'lib/rpath/adapter.rb', line 42 def adjacent(vertex) raise NotImplementedError end |
#attribute(vertex, name) ⇒ Object?
Returns the value of attribute name
of vertex
or nil
if no such attribute exists.
52 53 54 |
# File 'lib/rpath/adapter.rb', line 52 def attribute(vertex, name) raise NotImplementedError end |
#content(vertex) ⇒ Object?
Returns the content of vertex
or nil if no content exists.
60 61 62 |
# File 'lib/rpath/adapter.rb', line 60 def content(vertex) raise NotImplementedError end |
#name(vertex) ⇒ String
Returns the name of the given vertex
34 35 36 |
# File 'lib/rpath/adapter.rb', line 34 def name(vertex) raise NotImplementedError end |
#root(graph) ⇒ Object
Returns the root of the given graph, the vertex where evaluation begins. The default implementation returns the given graph. the given graph.
26 27 28 |
# File 'lib/rpath/adapter.rb', line 26 def root(graph) graph end |