Class: ActiveFacts::CQL::Compiler::Reciprocal
- Defined in:
- lib/activefacts/cql/compiler/expression.rb
Instance Attribute Summary collapse
-
#divisor ⇒ Object
Returns the value of attribute divisor.
Attributes inherited from Operation
#binding, #certainty, #clause, #fact_type, #player, #role, #role_ref
Instance Method Summary collapse
- #identify_player(context) ⇒ Object
-
#initialize(divisor) ⇒ Reciprocal
constructor
A new instance of Reciprocal.
-
#inspect ⇒ Object
def result_type_name(context) raise hell end.
- #operator ⇒ Object
- #refs ⇒ 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_type_name, #result_value_type, #role_name, #side_effects, #trailing_adjective, #value_constraint
Constructor Details
#initialize(divisor) ⇒ Reciprocal
Returns a new instance of Reciprocal.
318 319 320 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 318 def initialize divisor @divisor = divisor end |
Instance Attribute Details
#divisor ⇒ Object
Returns the value of attribute divisor.
317 318 319 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 317 def divisor @divisor end |
Instance Method Details
#identify_player(context) ⇒ Object
330 331 332 333 334 335 336 337 338 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 330 def identify_player context @player || begin # The player in @divisor has already been identified # REVISIT: Calculate the units of the result from the units in @divisor # REVISIT: Do we want integer division? v = context.vocabulary @player = v.constellation.ValueType(v, 'Real', :concept => :new) end end |
#inspect ⇒ Object
def result_type_name(context)
raise hell
end
346 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 346 def inspect; to_s; end |
#operator ⇒ Object
322 323 324 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 322 def operator '1/' end |
#refs ⇒ Object
326 327 328 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 326 def refs [@divisor] end |
#to_s ⇒ Object
348 349 350 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 348 def to_s "RECIPROCAL(#{factor.to_s})" end |