Class: RoadForest::PathMatcher::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/path-matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(matcher) ⇒ Match

Returns a new instance of Match.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/roadforest/path-matcher.rb', line 10

def initialize(matcher)
  @success = matcher.completed_child.accepting?
  @graph = if @success
      statements = matcher.completed_child.matched_statements.keys
      ::RDF::Graph.new.tap do |graph|
        statements.each do |stmt|
          graph << stmt
        end
      end
    end
end

Instance Method Details

#graphObject



28
29
30
31
32
33
34
# File 'lib/roadforest/path-matcher.rb', line 28

def graph
  if success?
    @graph
  else
    raise NoMatch, "Pattern doesn't match graph"
  end
end

#success?Boolean Also known as: successful?, succeed?

Returns:

  • (Boolean)


22
23
24
# File 'lib/roadforest/path-matcher.rb', line 22

def success?
  @success
end