Class: PgVerify::Model::Specification
- Inherits:
-
Object
- Object
- PgVerify::Model::Specification
- Defined in:
- lib/pg-verify/model/specs/specification.rb
Instance Attribute Summary collapse
-
#spec_sets ⇒ Object
Returns the value of attribute spec_sets.
Class Method Summary collapse
Instance Method Summary collapse
- #flatten ⇒ Object
- #get_specs ⇒ Object
-
#initialize(spec_sets) ⇒ Specification
constructor
A new instance of Specification.
Constructor Details
#initialize(spec_sets) ⇒ Specification
Returns a new instance of Specification.
12 13 14 |
# File 'lib/pg-verify/model/specs/specification.rb', line 12 def initialize(spec_sets) @spec_sets = spec_sets end |
Instance Attribute Details
#spec_sets ⇒ Object
Returns the value of attribute spec_sets.
6 7 8 |
# File 'lib/pg-verify/model/specs/specification.rb', line 6 def spec_sets @spec_sets end |
Class Method Details
.empty ⇒ Object
8 9 10 |
# File 'lib/pg-verify/model/specs/specification.rb', line 8 def self.empty() return self.new([]) end |
Instance Method Details
#flatten ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pg-verify/model/specs/specification.rb', line 20 def flatten() return get_specs().map { |spec| parents = spec.parents prefix = parents.map { |spec_set| spec_set.assumption.nil? \ ? spec_set.text \ : "(assuming #{spec_set.assumption[:text]})" #.c_sidenote }.join(" ") text = "#{prefix} #{spec.text}" assumption_expression = parents.map { |spec_set| next if spec_set.assumption.nil? spec_set.assumption[:expression] }.compact.join(" && ") expression = spec.expression unless assumption_expression.empty? expression_string = "( #{assumption_expression} ) => #{spec.expression}" expression = Model::ParsedExpression.new(expression_string, Model::ParsedExpression::TYPE_TL) expression.source_location = spec.expression.source_location end result = Spec.new(text, expression, nil) result.source_location = spec.source_location result } end |
#get_specs ⇒ Object
16 17 18 |
# File 'lib/pg-verify/model/specs/specification.rb', line 16 def get_specs() spec_sets.map(&:get_specs).flatten end |