Class: RegularExpression::NFA::State
- Inherits:
-
Object
- Object
- RegularExpression::NFA::State
- Defined in:
- lib/regular_expression/nfa.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #transitions ⇒ Object readonly
Instance Method Summary collapse
- #add_transition(transition) ⇒ Object
-
#initialize ⇒ State
constructor
A new instance of State.
- #to_dot(graph, visited) ⇒ Object
Constructor Details
#initialize ⇒ State
Returns a new instance of State.
16 17 18 |
# File 'lib/regular_expression/nfa.rb', line 16 def initialize @transitions = [] end |
Instance Attribute Details
#transitions ⇒ Object (readonly)
14 15 16 |
# File 'lib/regular_expression/nfa.rb', line 14 def transitions @transitions end |
Instance Method Details
#add_transition(transition) ⇒ Object
20 21 22 |
# File 'lib/regular_expression/nfa.rb', line 20 def add_transition(transition) transitions << transition end |
#to_dot(graph, visited) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/regular_expression/nfa.rb', line 24 def to_dot(graph, visited) return visited[self] if visited.include?(self) source = graph.add_node(object_id, label: "") visited[self] = source transitions.each do |transition| target = transition.state.to_dot(graph, visited) source.connect(target, label: transition.label) end source end |