Class: ActiveFacts::CQL::Compiler::ReadingMatchSideEffects
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::ReadingMatchSideEffects
- Defined in:
- lib/activefacts/cql/compiler/reading.rb
Instance Attribute Summary collapse
-
#fact_type ⇒ Object
readonly
Returns the value of attribute fact_type.
-
#residual_adjectives ⇒ Object
readonly
Returns the value of attribute residual_adjectives.
-
#role_side_effects ⇒ Object
readonly
One array of values per RoleRef matched, in order.
Instance Method Summary collapse
- #apply_all(&b) ⇒ Object
- #cost ⇒ Object
- #describe ⇒ Object
-
#initialize(fact_type, reading, residual_adjectives, role_side_effects) ⇒ ReadingMatchSideEffects
constructor
A new instance of ReadingMatchSideEffects.
Constructor Details
#initialize(fact_type, reading, residual_adjectives, role_side_effects) ⇒ ReadingMatchSideEffects
Returns a new instance of ReadingMatchSideEffects.
624 625 626 627 628 629 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 624 def initialize fact_type, reading, residual_adjectives, role_side_effects @fact_type = fact_type @reading = reading @residual_adjectives = residual_adjectives @role_side_effects = role_side_effects end |
Instance Attribute Details
#fact_type ⇒ Object (readonly)
Returns the value of attribute fact_type.
621 622 623 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 621 def fact_type @fact_type end |
#residual_adjectives ⇒ Object (readonly)
Returns the value of attribute residual_adjectives.
620 621 622 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 620 def residual_adjectives @residual_adjectives end |
#role_side_effects ⇒ Object (readonly)
One array of values per RoleRef matched, in order
622 623 624 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 622 def role_side_effects @role_side_effects end |
Instance Method Details
#apply_all(&b) ⇒ Object
631 632 633 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 631 def apply_all &b @role_side_effects.reverse.each{ |role_side_effect| b.call(*role_side_effect) } end |
#cost ⇒ Object
635 636 637 638 639 640 641 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 635 def cost c = 0 @role_side_effects.each do |se| c += se.cost end c + (@residual_adjectives ? 1 : 0) end |
#describe ⇒ Object
643 644 645 646 647 648 649 650 651 652 |
# File 'lib/activefacts/cql/compiler/reading.rb', line 643 def describe actual_effects = @role_side_effects.map do |se| ( [se.common_supertype ? "supertype join over #{se.common_supertype.name}" : nil] + [se.absorbed_precursors > 0 ? "absorbs #{se.absorbed_precursors} preceding words" : nil] + [se.absorbed_followers > 0 ? "absorbs #{se.absorbed_followers} following words" : nil] ) end.flatten.compact*',' actual_effects.empty? ? "no side effects" : actual_effects end |