Class: Kleene::State
- Inherits:
-
Object
- Object
- Kleene::State
- Defined in:
- lib/kleene/kleene.rb
Constant Summary collapse
- @@next_id =
0
Instance Attribute Summary collapse
-
#error ⇒ Object
: Bool.
-
#final ⇒ Object
: Bool.
-
#id ⇒ Object
readonly
: Int32.
Class Method Summary collapse
Instance Method Summary collapse
- #dup ⇒ Object
-
#error? ⇒ Boolean
is this an error state?.
-
#final? ⇒ Boolean
is this a final state?.
-
#initialize(final = false, error = false, id = nil) ⇒ State
constructor
A new instance of State.
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#error ⇒ Object
: Bool
33 34 35 |
# File 'lib/kleene/kleene.rb', line 33 def error @error end |
#final ⇒ Object
: Bool
32 33 34 |
# File 'lib/kleene/kleene.rb', line 32 def final @final end |
#id ⇒ Object (readonly)
: Int32
31 32 33 |
# File 'lib/kleene/kleene.rb', line 31 def id @id end |
Class Method Details
.new_error_state(final = false) ⇒ Object
27 28 29 |
# File 'lib/kleene/kleene.rb', line 27 def self.new_error_state(final = false) State.new(final, true) end |
.next_id ⇒ Object
23 24 25 |
# File 'lib/kleene/kleene.rb', line 23 def self.next_id @@next_id += 1 end |
Instance Method Details
#dup ⇒ Object
51 52 53 |
# File 'lib/kleene/kleene.rb', line 51 def dup State.new(@final, @error, nil) end |
#error? ⇒ Boolean
is this an error state?
42 43 44 |
# File 'lib/kleene/kleene.rb', line 42 def error? @error end |
#final? ⇒ Boolean
is this a final state?
47 48 49 |
# File 'lib/kleene/kleene.rb', line 47 def final? @final end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/kleene/kleene.rb', line 55 def to_s "State{id: #{id}, final: #{final}, error: #{error}}" end |