Class: PgVerify::Model::Graph
- Inherits:
-
Object
- Object
- PgVerify::Model::Graph
- Defined in:
- lib/pg-verify/model/graph.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
All Model::Component’s which are part of this graph.
-
#hazards ⇒ Object
An array of Model::Hazards for this graph.
-
#name ⇒ Object
The name of this graph.
-
#specification ⇒ Object
The Model::Specification of this graph.
-
#variables ⇒ Object
A Model::VariableSet of all non-state variables declared by components in this graph.
Instance Method Summary collapse
-
#all_variables ⇒ Object
Returns all variables used in this graph including state variables.
- #fault_components ⇒ Object
-
#initialize(name, components: [], variables: VariableSet.new(), specification: Specification.empty(), hazards: []) ⇒ Graph
constructor
A new instance of Graph.
-
#state_variables ⇒ Object
Returns a list of state variables for each component in this graph Each state variable is named according to the component it represents and has a range consisting of the states of that component.
- #validate ⇒ Object
Constructor Details
#initialize(name, components: [], variables: VariableSet.new(), specification: Specification.empty(), hazards: []) ⇒ Graph
Returns a new instance of Graph.
23 24 25 26 27 28 |
# File 'lib/pg-verify/model/graph.rb', line 23 def initialize(name, components: [], variables: VariableSet.new(), specification: Specification.empty(), hazards: []) raise "Not a variable set #{variables}" unless variables.is_a?(VariableSet) raise "Not a specification #{specification}" unless specification.is_a?(Specification) @name = name @components, @variables, @specification, @hazards = components, variables, specification, hazards end |
Instance Attribute Details
#components ⇒ Object
All Model::Component’s which are part of this graph
11 12 13 |
# File 'lib/pg-verify/model/graph.rb', line 11 def components @components end |
#hazards ⇒ Object
An array of Model::Hazards for this graph
21 22 23 |
# File 'lib/pg-verify/model/graph.rb', line 21 def hazards @hazards end |
#name ⇒ Object
The name of this graph
8 9 10 |
# File 'lib/pg-verify/model/graph.rb', line 8 def name @name end |
#specification ⇒ Object
The Model::Specification of this graph
18 19 20 |
# File 'lib/pg-verify/model/graph.rb', line 18 def specification @specification end |
#variables ⇒ Object
A Model::VariableSet of all non-state variables declared by components in this graph
15 16 17 |
# File 'lib/pg-verify/model/graph.rb', line 15 def variables @variables end |
Instance Method Details
#all_variables ⇒ Object
Returns all variables used in this graph including state variables
41 42 43 |
# File 'lib/pg-verify/model/graph.rb', line 41 def all_variables() return state_variables() + @variables end |
#fault_components ⇒ Object
45 46 47 |
# File 'lib/pg-verify/model/graph.rb', line 45 def fault_components() return @components.select(&:represents_fault?) end |
#state_variables ⇒ Object
Returns a list of state variables for each component in this graph Each state variable is named according to the component it represents and has a range consisting of the states of that component
33 34 35 36 37 38 |
# File 'lib/pg-verify/model/graph.rb', line 33 def state_variables() vars = @components.map { |cmp| Variable.new(cmp.name, cmp.states, cmp.name, cmp.source_location) } return VariableSet.new(*vars) end |
#validate ⇒ Object
49 50 51 52 53 |
# File 'lib/pg-verify/model/graph.rb', line 49 def validate() errors = [] errors += UnkownVariableValidation.validate(self) return errors end |