Class: Stamina::Automaton::Determinize::CompoundState
- Inherits:
-
Object
- Object
- Stamina::Automaton::Determinize::CompoundState
- Defined in:
- lib/stamina-core/stamina/automaton/determinize.rb
Instance Attribute Summary collapse
-
#fa ⇒ Object
readonly
Returns the value of attribute fa.
-
#initial ⇒ Object
readonly
Returns the value of attribute initial.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #delta(symbol) ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(fa, states, initial = false) ⇒ CompoundState
constructor
A new instance of CompoundState.
- #marks ⇒ Object
Constructor Details
#initialize(fa, states, initial = false) ⇒ CompoundState
Returns a new instance of CompoundState.
11 12 13 14 15 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 11 def initialize(fa, states, initial = false) @fa = fa @states = states.sort @initial = initial end |
Instance Attribute Details
#fa ⇒ Object (readonly)
Returns the value of attribute fa.
7 8 9 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 7 def fa @fa end |
#initial ⇒ Object (readonly)
Returns the value of attribute initial.
9 10 11 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 9 def initial @initial end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
8 9 10 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 8 def states @states end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
39 40 41 42 43 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 39 def ==(other) other.is_a?(CompoundState) && (other.fa == self.fa) && (other.states == self.states) end |
#delta(symbol) ⇒ Object
31 32 33 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 31 def delta(symbol) CompoundState.new(fa, fa.delta(states, symbol)) end |
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 17 def empty? states.empty? end |
#hash ⇒ Object
35 36 37 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 35 def hash @states.hash end |
#marks ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/stamina-core/stamina/automaton/determinize.rb', line 21 def marks @marks ||= begin marks = {} marks[:initial] = initial marks[:accepting] = states.any?{|s| s.accepting?} marks[:error] = states.any?{|s| s.error?} marks end end |