Class: PgVerify::Model::Transition
- Inherits:
-
Object
- Object
- PgVerify::Model::Transition
- Defined in:
- lib/pg-verify/model/transition.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#guard ⇒ Object
Returns the value of attribute guard.
-
#precon ⇒ Object
Returns the value of attribute precon.
-
#src_state ⇒ Object
The source and target state of this transition as symbols.
-
#tgt_state ⇒ Object
The source and target state of this transition as symbols.
Instance Method Summary collapse
-
#initialize(src_state, tgt_state, guard: nil, action: nil, precon: nil) ⇒ Transition
constructor
A new instance of Transition.
- #to_s ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(src_state, tgt_state, guard: nil, action: nil, precon: nil) ⇒ Transition
Returns a new instance of Transition.
11 12 13 14 |
# File 'lib/pg-verify/model/transition.rb', line 11 def initialize(src_state, tgt_state, guard: nil, action: nil, precon: nil) @src_state, @tgt_state = src_state, tgt_state @guard, @precon, @action = guard, precon, action end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'lib/pg-verify/model/transition.rb', line 9 def action @action end |
#guard ⇒ Object
Returns the value of attribute guard.
9 10 11 |
# File 'lib/pg-verify/model/transition.rb', line 9 def guard @guard end |
#precon ⇒ Object
Returns the value of attribute precon.
9 10 11 |
# File 'lib/pg-verify/model/transition.rb', line 9 def precon @precon end |
#src_state ⇒ Object
The source and target state of this transition as symbols
7 8 9 |
# File 'lib/pg-verify/model/transition.rb', line 7 def src_state @src_state end |
#tgt_state ⇒ Object
The source and target state of this transition as symbols
7 8 9 |
# File 'lib/pg-verify/model/transition.rb', line 7 def tgt_state @tgt_state end |
Instance Method Details
#to_s ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/pg-verify/model/transition.rb', line 30 def to_s() label = [ @precon, @guard ].map(&:to_s).reject(&:empty?).join(" && ") label += "/ " + @action.to_s unless @action.nil? label = ": #{label}" unless label.strip.empty? return "#{@src_state} -> #{@tgt_state} #{label}" end |
#validate! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pg-verify/model/transition.rb', line 16 def validate!() # @actions.each { |action| # # Calculate all illegal allocations # # An allocation is illegal if it evaluates to a number outside of the range # # of the assigned variable # illegal_allocations = action.calc_illegal_allocations() # # Only keep allocations as illegal if guards do not prevent them # illegal_allocations = precon.filter_allocation_set(illegal_allocations) # raise("ValidationError") if illegal_allocations.length != 0 # } end |