Class: PgVerify::Model::Transition

Inherits:
Object
  • Object
show all
Defined in:
lib/pg-verify/model/transition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionObject

Returns the value of attribute action.



9
10
11
# File 'lib/pg-verify/model/transition.rb', line 9

def action
  @action
end

#guardObject

Returns the value of attribute guard.



9
10
11
# File 'lib/pg-verify/model/transition.rb', line 9

def guard
  @guard
end

#preconObject

Returns the value of attribute precon.



9
10
11
# File 'lib/pg-verify/model/transition.rb', line 9

def precon
  @precon
end

#src_stateObject

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_stateObject

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_sObject



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