Class: ActiveFacts::CQL::Compiler::Product
- Defined in:
- lib/activefacts/cql/compiler/expression.rb
Instance Attribute Summary collapse
-
#factors ⇒ Object
Returns the value of attribute factors.
Attributes inherited from Operation
#binding, #certainty, #clause, #fact_type, #player, #role, #role_ref
Instance Method Summary collapse
- #identify_player(context) ⇒ Object
-
#initialize(*factors) ⇒ Product
constructor
A new instance of Product.
-
#inspect ⇒ Object
def result_value_type(context, name) vt = super # REVISIT: If there are units involved, create the result units vt end.
- #operator ⇒ Object
- #refs ⇒ Object
- #result_type_name(context) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Operation
#bind, #conjunction, #identify_other_players, #identify_players_with_role_name, #is_equality_comparison, #is_naked_object_type, #leading_adjective, #literal, #match_existing_fact_type, #nested_clauses, #objectification_of, #objectified_as, #operands, #result_value_type, #role_name, #side_effects, #trailing_adjective, #value_constraint
Constructor Details
#initialize(*factors) ⇒ Product
Returns a new instance of Product.
274 275 276 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 274 def initialize *factors @factors = factors end |
Instance Attribute Details
#factors ⇒ Object
Returns the value of attribute factors.
273 274 275 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 273 def factors @factors end |
Instance Method Details
#identify_player(context) ⇒ Object
286 287 288 289 290 291 292 293 294 295 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 286 def identify_player context @player || begin # The players in the @factors have already been identified # REVISIT: Calculate the units of the result from the units in @factors # REVISIT: The type of this result should be derived from type promotion rules. Here, we take the left-most. # REVISIT: We should define a subtype of the result type here, and apply the units to it. v = context.vocabulary @player = @factors[0].player end end |
#inspect ⇒ Object
def result_value_type(context, name)
vt = super
# REVISIT: If there are units involved, create the result units
vt
end
309 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 309 def inspect; to_s; end |
#operator ⇒ Object
282 283 284 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 282 def operator '*' end |
#refs ⇒ Object
278 279 280 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 278 def refs @factors end |
#result_type_name(context) ⇒ Object
297 298 299 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 297 def result_type_name(context) "PRODUCT_OF<#{ @factors.map{|f| f.player.name}*' ' }>" end |
#to_s ⇒ Object
311 312 313 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 311 def to_s 'PRODUCT(' + @factors.map{|factor| "#{factor.to_s}" } * ' TIMES ' + ')' end |