blob: 5875e388dc35c25792347ed557c094e10d2fd516 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
module VFSM
class Node
def initialize id, accepting = false
@id = id
@accepting = accepting
@edges = []
end
def id
return @id
end
def accepting! accepting=true
@accepting = accepting
end
def accepting?
return @accepting
end
def pushedge on, to
tempto = @edges.select do |edge|
edge[0] == on
end
@edges.push [on, to]
end
def goto on
to = @edges.select do |edge|
edge[0] == on
end
if to.length == 0 then
return :reject
else
ret = []
to.each do |x|
ret.push x[1]
end
return ret
end
end
end
end
|