Module: RGL::GraphVisitor::ClassMethods

### Home Classes Methods

### In Files

- lib/rgl/graph_visitor.rb

### Methods

- #def_event_handler
- #def_event_handlers

### Class/Module Index

Quicksearch

- RGL
- RGL::AdjacencyGraph
- RGL::BFSIterator
- RGL::BellmanFordAlgorithm
- RGL::BellmanFordVisitor
- RGL::BidirectionalGraph
- RGL::BipartiteBFSIterator
- RGL::DFSIterator
- RGL::DFSVisitor
- RGL::DOT
- RGL::DOT::Digraph
- RGL::DOT::DirectedEdge
- RGL::DOT::Edge
- RGL::DOT::Element
- RGL::DOT::Graph
- RGL::DOT::Node
- RGL::DOT::Port
- RGL::DOT::Subgraph
- RGL::DijkstraAlgorithm
- RGL::DijkstraVisitor
- RGL::DirectedAdjacencyGraph
- RGL::Edge
- RGL::Edge::DirectedEdge
- RGL::Edge::UnDirectedEdge
- RGL::EdgePropertiesMap
- RGL::EdmondsKarpAlgorithm
- RGL::EdmondsKarpAlgorithm::EdmondsKarpBFSIterator
- RGL::Graph
- RGL::Graph::TarjanSccVisitor
- RGL::GraphIterator
- RGL::GraphVisitor
- RGL::GraphVisitor::ClassMethods
- RGL::GraphVisitor::DistanceMapSupport
- RGL::ImplicitGraph
- RGL::MutableGraph
- RGL::MutableGraph::MutableGraphParser
- RGL::NoEdgeError
- RGL::NoVertexError
- RGL::NonNegativeEdgePropertiesMap
- RGL::NotDirectedError
- RGL::NotUndirectedError
- RGL::PrimAlgorithm
- RGL::TopsortIterator
- Enumerable
- Object

No matching classes.

# RGL::GraphVisitor::ClassMethods

### Public Instance Methods

def_event_handler(*events) click to toggle source
Alias for: def_event_handlers
def_event_handlers(*events) click to toggle source

Defines an event handler.

    # File lib/rgl/graph_visitor.rb, line 101
    def def_event_handlers(*events)
      events.each do |event|
        params = event.to_s.include?('edge') ? 'u, v' : 'u'

        handler = "@#{event}_event_handler"

        class_eval             def handle_#{event}(#{params})              #{handler}.call(#{params}) if defined? #{handler}            end            def set_#{event}_event_handler(&block)              #{handler} = block            end
      end
    end

Also aliased as: def_event_handler

[Validate]

Generated with the Darkfish Rdoc Generator 2.