lib/Node.rb in re_expand-0.0.1 vs lib/Node.rb in re_expand-0.0.2
- old
+ new
@@ -6,58 +6,60 @@
# ■ ----------> □
# ----------> □
# ----------> □
#
-class Trans
- def initialize(pat,dest)
- # pat にマッチしたら dest に遷移
- @pat = pat
- @dest = dest
- end
-
- attr_reader :pat, :dest
-
- def str
- @pat.split(/\t/)[0].to_s
- end
-
- def arg
- if @pat =~ /^(.*)\t(.*)$/ then
- return $2
- else
- return @pat
+module ReExpand
+ class Trans
+ def initialize(pat,dest)
+ # pat にマッチしたら dest に遷移
+ @pat = pat
+ @dest = dest
end
+
+ attr_reader :pat, :dest
+
+ def str
+ @pat.split(/\t/)[0].to_s
+ end
+
+ def arg
+ if @pat =~ /^(.*)\t(.*)$/ then
+ return $2
+ else
+ return @pat
+ end
+ end
end
-end
-
-class Node
- @@id = 1
- @@nodes = {}
-
- def initialize
- @accept = nil
- @trans = []
- @id = @@id
- @@nodes[@id] = self
- @@id += 1
- @pars = []
- end
-
- attr_reader :id
- attr_reader :trans
- attr :accept, true
- attr :pars, true
-
- def addTrans(pat,dest)
- t = Trans.new(pat,dest)
- @trans << t
- end
-
- def Node.node(id) # ノードidからノードを取得
- @@nodes[id.to_i]
- end
-
- def Node.nodes
- @@nodes.values
+
+ class Node
+ @@id = 1
+ @@nodes = {}
+
+ def initialize
+ @accept = nil
+ @trans = []
+ @id = @@id
+ @@nodes[@id] = self
+ @@id += 1
+ @pars = []
+ end
+
+ attr_reader :id
+ attr_reader :trans
+ attr :accept, true
+ attr :pars, true
+
+ def addTrans(pat,dest)
+ t = Trans.new(pat,dest)
+ @trans << t
+ end
+
+ def Node.node(id) # ノードidからノードを取得
+ @@nodes[id.to_i]
+ end
+
+ def Node.nodes
+ @@nodes.values
+ end
end
end