Class: StateShifter::Event
- Inherits:
-
Object
- Object
- StateShifter::Event
- Defined in:
- lib/state_shifter/event.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#guards ⇒ Object
readonly
Returns the value of attribute guards.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #draw(graph, options = {}) ⇒ Object
- #has_callback? ⇒ Boolean
- #has_guards? ⇒ Boolean
-
#initialize(from, name, to = nil, guards = nil, callback = nil) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(from, name, to = nil, guards = nil, callback = nil) ⇒ Event
Returns a new instance of Event.
5 6 7 8 9 10 11 |
# File 'lib/state_shifter/event.rb', line 5 def initialize from, name, to=nil, guards=nil, callback=nil @name = name @from = from @to = to @guards = [guards].flatten.compact @callback = callback end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
3 4 5 |
# File 'lib/state_shifter/event.rb', line 3 def callback @callback end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
3 4 5 |
# File 'lib/state_shifter/event.rb', line 3 def from @from end |
#guards ⇒ Object (readonly)
Returns the value of attribute guards.
3 4 5 |
# File 'lib/state_shifter/event.rb', line 3 def guards @guards end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/state_shifter/event.rb', line 3 def name @name end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
3 4 5 |
# File 'lib/state_shifter/event.rb', line 3 def to @to end |
Instance Method Details
#draw(graph, options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/state_shifter/event.rb', line 21 def draw(graph, = {}) to = @to ? @to : @from graph.add_edges(@from.to_s, to.to_s, :label => @name.to_s) end |
#has_callback? ⇒ Boolean
17 18 19 |
# File 'lib/state_shifter/event.rb', line 17 def has_callback? !@callback.nil? end |
#has_guards? ⇒ Boolean
13 14 15 |
# File 'lib/state_shifter/event.rb', line 13 def has_guards? !@guards.nil? end |