Class: StatefulEnum::Graph::EventDrawer
- Inherits:
-
Machine::Event
- Object
- Machine::Event
- StatefulEnum::Graph::EventDrawer
- Defined in:
- lib/generators/stateful_enum/graph_generator.rb
Instance Method Summary collapse
-
#initialize(g, states, prefix, suffix, name, &block) ⇒ EventDrawer
constructor
A new instance of EventDrawer.
- #transition(transitions, options = {}) ⇒ Object
Methods inherited from Machine::Event
Constructor Details
#initialize(g, states, prefix, suffix, name, &block) ⇒ EventDrawer
Returns a new instance of EventDrawer.
51 52 53 54 55 56 |
# File 'lib/generators/stateful_enum/graph_generator.rb', line 51 def initialize(g, states, prefix, suffix, name, &block) @g, @states, @prefix, @suffix, @name = g, states, prefix, suffix, name @before, @after = [], [] instance_eval(&block) if block end |
Instance Method Details
#transition(transitions, options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/stateful_enum/graph_generator.rb', line 58 def transition(transitions, = {}) if .blank? transitions.delete :if transitions.delete :unless end transitions.each_pair do |from, to| Array(from).each do |f| @g.add_edge f.to_s, to.to_s, label: "#{@prefix}#{@name}#{@suffix}" end end end |