Class: RPath::Adapter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rpath/adapter.rb

Overview

This class is abstract.

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.

Instance Method Summary collapse

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.

Parameters:

  • graph (Object)

Returns:

  • (Boolean)

See Also:



17
18
19
# File 'lib/rpath/adapter.rb', line 17

def adapts?(graph)
  false
end

#adjacent(vertex) ⇒ Array

This method is abstract.

Returns the vertices adjacent to the given vertex.

Parameters:

  • vertex (Object)

Returns:

  • (Array)

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/rpath/adapter.rb', line 42

def adjacent(vertex)
  raise NotImplementedError
end

#attribute(vertex, name) ⇒ Object?

This method is abstract.

Returns the value of attribute name of vertex or nil if no such attribute exists.

Parameters:

  • vertex (Object)
  • name (String, Symbol)

Returns:

  • (Object, nil)

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/rpath/adapter.rb', line 52

def attribute(vertex, name)
  raise NotImplementedError
end

#content(vertex) ⇒ Object?

This method is abstract.

Returns the content of vertex or nil if no content exists.

Parameters:

  • vertex (Object)

Returns:

  • (Object, nil)

Raises:

  • (NotImplementedError)


60
61
62
# File 'lib/rpath/adapter.rb', line 60

def content(vertex)
  raise NotImplementedError
end

#name(vertex) ⇒ String

This method is abstract.

Returns the name of the given vertex

Parameters:

  • vertex (Object)

Returns:

  • (String)

Raises:

  • (NotImplementedError)


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.

Parameters:

  • graph (Object)

Returns:

  • (Object)


26
27
28
# File 'lib/rpath/adapter.rb', line 26

def root(graph)
  graph
end