Class: RoadForest::PathMatcher::MatchStep

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

Direct Known Subclasses

Edge, Node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ MatchStep

Returns a new instance of MatchStep.

Yields:

  • (_self)

Yield Parameters:



51
52
53
54
55
56
57
58
# File 'lib/roadforest/path-matcher.rb', line 51

def initialize
  @children = nil
  reset
  yield self
  @satisfied ||= {}
  @stem ||= {}
  @repeats ||= {}
end

Instance Attribute Details

#afterObject

Returns the value of attribute after.



47
48
49
# File 'lib/roadforest/path-matcher.rb', line 47

def after
  @after
end

#beforeObject

Returns the value of attribute before.



47
48
49
# File 'lib/roadforest/path-matcher.rb', line 47

def before
  @before
end

#childrenObject (readonly)

Returns the value of attribute children.



49
50
51
# File 'lib/roadforest/path-matcher.rb', line 49

def children
  @children
end

#exact_valueObject

Returns the value of attribute exact_value.



47
48
49
# File 'lib/roadforest/path-matcher.rb', line 47

def exact_value
  @exact_value
end

#graphObject

Returns the value of attribute graph.



43
44
45
# File 'lib/roadforest/path-matcher.rb', line 43

def graph
  @graph
end

#graph_termObject

Returns the value of attribute graph_term.



44
45
46
# File 'lib/roadforest/path-matcher.rb', line 44

def graph_term
  @graph_term
end

#orderObject

Returns the value of attribute order.



47
48
49
# File 'lib/roadforest/path-matcher.rb', line 47

def order
  @order
end

#parentObject

Returns the value of attribute parent.



38
39
40
# File 'lib/roadforest/path-matcher.rb', line 38

def parent
  @parent
end

#patternObject

Returns the value of attribute pattern.



42
43
44
# File 'lib/roadforest/path-matcher.rb', line 42

def pattern
  @pattern
end

#pattern_stepObject

Returns the value of attribute pattern_step.



45
46
47
# File 'lib/roadforest/path-matcher.rb', line 45

def pattern_step
  @pattern_step
end

#repeatsObject

Returns the value of attribute repeats.



40
41
42
# File 'lib/roadforest/path-matcher.rb', line 40

def repeats
  @repeats
end

#satifiedObject

Returns the value of attribute satified.



41
42
43
# File 'lib/roadforest/path-matcher.rb', line 41

def satified
  @satified
end

#stemObject

Returns the value of attribute stem.



39
40
41
# File 'lib/roadforest/path-matcher.rb', line 39

def stem
  @stem
end

#typeObject

Returns the value of attribute type.



47
48
49
# File 'lib/roadforest/path-matcher.rb', line 47

def type
  @type
end

Instance Method Details

#immediate_matchObject



69
70
71
# File 'lib/roadforest/path-matcher.rb', line 69

def immediate_match
  {}
end

#matched_statementsObject



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/roadforest/path-matcher.rb', line 83

def matched_statements
  return {} unless accepting?
  @matched_statements ||=
    begin
      children.map do |child|
        child.matched_statements
      end.inject(immediate_match) do |set, matched|
        set.merge(matched)
      end
    end
end

#openObject



73
74
75
76
77
78
79
80
81
# File 'lib/roadforest/path-matcher.rb', line 73

def open
  if excluded?
    return @children = []
  end

  @children ||= build_children

  return children
end

#pretty_print_instance_variablesObject



63
64
65
66
67
# File 'lib/roadforest/path-matcher.rb', line 63

def pretty_print_instance_variables
  instance_variables.reject do |var|
    var == :@parent
  end
end

#resetObject



60
61
# File 'lib/roadforest/path-matcher.rb', line 60

def reset
end