Class: ActiveFacts::CQL::Compiler::Reciprocal

Inherits:
Operation
  • Object
show all
Defined in:
lib/activefacts/cql/compiler/expression.rb

Instance Attribute Summary collapse

Attributes inherited from Operation

#binding, #certainty, #clause, #fact_type, #player, #role, #role_ref

Instance Method Summary collapse

Methods inherited from Operation

#bind, #conjunction, #identify_other_players, #identify_players_with_role_name, #is_equality_comparison, #is_existential_type, #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.



322
323
324
# File 'lib/activefacts/cql/compiler/expression.rb', line 322

def initialize divisor
  @divisor = divisor
end

Instance Attribute Details

#divisorObject

Returns the value of attribute divisor.



321
322
323
# File 'lib/activefacts/cql/compiler/expression.rb', line 321

def divisor
  @divisor
end

Instance Method Details

#identify_player(context) ⇒ Object



334
335
336
337
338
339
340
341
342
# File 'lib/activefacts/cql/compiler/expression.rb', line 334

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

#inspectObject

def result_type_name(context)

  raise hell
end


350
# File 'lib/activefacts/cql/compiler/expression.rb', line 350

def inspect; to_s; end

#operatorObject



326
327
328
# File 'lib/activefacts/cql/compiler/expression.rb', line 326

def operator
  '1/'
end

#refsObject



330
331
332
# File 'lib/activefacts/cql/compiler/expression.rb', line 330

def refs
  [@divisor]
end

#to_sObject



352
353
354
# File 'lib/activefacts/cql/compiler/expression.rb', line 352

def to_s
  "reciprocal(#{factor.to_s})"
end