1#
2# The contents of this file are subject to the Mozilla Public
3# License Version 1.1 (the "License"); you may not use this file
4# except in compliance with the License. You may obtain a copy of
5# the License at http://www.mozilla.org/MPL/
6#
7# Software distributed under the License is distributed on an "AS
8# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9# implied. See the License for the specific language governing
10# rights and limitations under the License.
11#
12# The Original Code is State Machine Compiler (SMC).
13#
14# The Initial Developer of the Original Code is Charles W. Rapp.
15# Portions created by Charles W. Rapp are
16# Copyright (C) 2000 - 2003 Charles W. Rapp.
17# All Rights Reserved.
18#
19# Contributor(s):
20#       Port to Ruby by Francois Perrad, francois.perrad@gadz.org
21#
22# Function
23#   Main
24#
25# Description
26#  This routine starts the finite state machine running.
27#
28# RCS ID
29# $Id: AppClass.rb,v 1.1 2005/06/16 17:52:03 fperrad Exp $
30#
31# CHANGE LOG
32# $Log: AppClass.rb,v $
33# Revision 1.1  2005/06/16 17:52:03  fperrad
34# Added Ruby examples 1 - 4 and 7.
35#
36#
37
38require 'AppClass_sm'
39
40class AppClass
41
42	def initialize()
43		@_fsm = AppClass_sm::new(self)
44		@_is_acceptable = nil
45
46		# Uncomment to see debug output.
47		#@_fsm.setDebugFlag(true)
48	end
49
50	def CheckString(string)
51		for c in string.split(//) do
52			if c == '0' then
53				@_fsm.Zero
54			elsif c == '1' then
55				@_fsm.One
56			else
57				@_fsm.Unknown
58			end
59		end
60		@_fsm.EOS()
61		return @_is_acceptable
62	end
63
64	def Acceptable()
65		@_is_acceptable = true
66	end
67
68	def Unacceptable()
69		@_is_acceptable = false
70	end
71
72end
73