Class: Hoozuki::Automaton::StateID

Inherits:
Object
  • Object
show all
Defined in:
lib/hoozuki/automaton/state_id.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ StateID

Returns a new instance of StateID.



8
9
10
# File 'lib/hoozuki/automaton/state_id.rb', line 8

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hoozuki/automaton/state_id.rb', line 6

def id
  @id
end

Class Method Details

.new_stateObject



13
14
15
16
# File 'lib/hoozuki/automaton/state_id.rb', line 13

def new_state
  @id += 1
  StateID.new(@id)
end

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
27
28
# File 'lib/hoozuki/automaton/state_id.rb', line 24

def <=>(other)
  return nil unless other.is_a?(StateID)

  @id <=> other.id
end

#new_stateObject



19
20
21
22
# File 'lib/hoozuki/automaton/state_id.rb', line 19

def new_state
  @id += 1
  StateID.new(@id)
end