Class: ActiveFacts::CQL::Compiler::ClauseMatchSideEffects
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::ClauseMatchSideEffects
- Defined in:
- lib/activefacts/cql/compiler/clause.rb
Instance Attribute Summary collapse
-
#fact_type ⇒ Object
readonly
Returns the value of attribute fact_type.
-
#negated ⇒ Object
readonly
Returns the value of attribute negated.
-
#optional ⇒ Object
readonly
Returns the value of attribute optional.
-
#residual_adjectives ⇒ Object
readonly
Returns the value of attribute residual_adjectives.
-
#role_side_effects ⇒ Object
readonly
One array of values per Reference matched, in order.
Instance Method Summary collapse
- #apply_all(&b) ⇒ Object
- #cost ⇒ Object
- #describe ⇒ Object
-
#initialize(fact_type, clause, residual_adjectives, role_side_effects, negated = false) ⇒ ClauseMatchSideEffects
constructor
A new instance of ClauseMatchSideEffects.
- #inspect ⇒ Object
Constructor Details
#initialize(fact_type, clause, residual_adjectives, role_side_effects, negated = false) ⇒ ClauseMatchSideEffects
Returns a new instance of ClauseMatchSideEffects.
836 837 838 839 840 841 842 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 836 def initialize fact_type, clause, residual_adjectives, role_side_effects, negated = false @fact_type = fact_type @clause = clause @residual_adjectives = residual_adjectives @role_side_effects = role_side_effects @negated = negated end |
Instance Attribute Details
#fact_type ⇒ Object (readonly)
Returns the value of attribute fact_type.
831 832 833 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 831 def fact_type @fact_type end |
#negated ⇒ Object (readonly)
Returns the value of attribute negated.
833 834 835 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 833 def negated @negated end |
#optional ⇒ Object (readonly)
Returns the value of attribute optional.
834 835 836 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 834 def optional @optional end |
#residual_adjectives ⇒ Object (readonly)
Returns the value of attribute residual_adjectives.
830 831 832 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 830 def residual_adjectives @residual_adjectives end |
#role_side_effects ⇒ Object (readonly)
One array of values per Reference matched, in order
832 833 834 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 832 def role_side_effects @role_side_effects end |
Instance Method Details
#apply_all(&b) ⇒ Object
852 853 854 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 852 def apply_all &b @role_side_effects.reverse.each{ |role_side_effect| b.call(*role_side_effect) } end |
#cost ⇒ Object
856 857 858 859 860 861 862 863 864 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 856 def cost c = 0 @role_side_effects.each do |side_effect| c += side_effect.cost end c += 1 if @residual_adjectives c += 2 if @negated c end |
#describe ⇒ Object
866 867 868 869 870 871 872 873 874 875 876 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 866 def describe actual_effects = @role_side_effects.map do |side_effect| ( [side_effect.common_supertype ? "supertype step over #{side_effect.common_supertype.name}" : nil] + [side_effect.absorbed_precursors > 0 ? "absorbs #{side_effect.absorbed_precursors} preceding words" : nil] + [side_effect.absorbed_followers > 0 ? "absorbs #{side_effect.absorbed_followers} following words" : nil] + [@negated ? 'implicitly negated' : nil] ) end.flatten.compact*',' actual_effects.empty? ? "no side effects" : actual_effects end |
#inspect ⇒ Object
844 845 846 847 848 849 850 |
# File 'lib/activefacts/cql/compiler/clause.rb', line 844 def inspect 'side-effects are [' + @role_side_effects.map{|r| r.to_s}*', ' + ']' + "#{@negated ? ' negated' : ''}" + "#{@residual_adjectives ? ' with residual adjectives' : ''}" end |