Class: Toaster::TransitionEdge
- Inherits:
-
Object
- Object
- Toaster::TransitionEdge
- Defined in:
- lib/toaster/state/transition_edge.rb
Instance Attribute Summary collapse
-
#disjunctive_conditions ⇒ Object
Returns the value of attribute disjunctive_conditions.
-
#node_from ⇒ Object
Returns the value of attribute node_from.
-
#node_to ⇒ Object
Returns the value of attribute node_to.
-
#transition ⇒ Object
Returns the value of attribute transition.
Instance Method Summary collapse
-
#initialize(node_from, node_to, conditions = [], transition = nil) ⇒ TransitionEdge
constructor
A new instance of TransitionEdge.
- #matches_parameters?(task_parameters) ⇒ Boolean
- #matches_states?(prestate, poststate) ⇒ Boolean
-
#represented_task ⇒ Object
each state transition represents the execution of an automation task.
Constructor Details
#initialize(node_from, node_to, conditions = [], transition = nil) ⇒ TransitionEdge
Returns a new instance of TransitionEdge.
13 14 15 16 17 18 19 |
# File 'lib/toaster/state/transition_edge.rb', line 13 def initialize(node_from, node_to, conditions=[], transition=nil) @node_from = node_from @node_to = node_to @disjunctive_conditions = conditions @disjunctive_conditions = [] if !conditions @transition = transition end |
Instance Attribute Details
#disjunctive_conditions ⇒ Object
Returns the value of attribute disjunctive_conditions.
11 12 13 |
# File 'lib/toaster/state/transition_edge.rb', line 11 def disjunctive_conditions @disjunctive_conditions end |
#node_from ⇒ Object
Returns the value of attribute node_from.
11 12 13 |
# File 'lib/toaster/state/transition_edge.rb', line 11 def node_from @node_from end |
#node_to ⇒ Object
Returns the value of attribute node_to.
11 12 13 |
# File 'lib/toaster/state/transition_edge.rb', line 11 def node_to @node_to end |
#transition ⇒ Object
Returns the value of attribute transition.
11 12 13 |
# File 'lib/toaster/state/transition_edge.rb', line 11 def transition @transition end |
Instance Method Details
#matches_parameters?(task_parameters) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/toaster/state/transition_edge.rb', line 34 def matches_parameters?(task_parameters) @disjunctive_conditions.each do |condition| all_contained = true condition.each do |key,value| contained = false task_parameters.each do |tp_key,tp_val| if key == tp_key if value.eql?(tp_val) contained = true break end end end if !contained all_contained = false break end end return true if all_contained end return false end |
#matches_states?(prestate, poststate) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/toaster/state/transition_edge.rb', line 57 def matches_states?(prestate, poststate) return false if !@node_from.subset_of?(prestate) return false if !@node_to.subset_of?(poststate) return true end |
#represented_task ⇒ Object
each state transition represents the execution of an automation task
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/toaster/state/transition_edge.rb', line 22 def represented_task() t = @node_to.preceding_task() if @node_from.properties.include?("__task_num__") && @node_to.properties.include?("__task_num__") # in a "backwards" transition no particular task execution is represented if @node_from.properties["__task_num__"] > @node_to.properties["__task_num__"] return nil end end return t if t return @node_from.succeeding_task end |