Class: ActiveFacts::CQL::Compiler::Aggregate

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_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(operation, aggregand) ⇒ Aggregate

Returns a new instance of Aggregate.



584
585
586
587
# File 'lib/activefacts/cql/compiler/expression.rb', line 584

def initialize operation, aggregand
  @operation = operation
  @aggregand = aggregand
end

Instance Attribute Details

#aggregandObject

Returns the value of attribute aggregand.



583
584
585
# File 'lib/activefacts/cql/compiler/expression.rb', line 583

def aggregand
  @aggregand
end

#operationObject

Returns the value of attribute operation.



583
584
585
# File 'lib/activefacts/cql/compiler/expression.rb', line 583

def operation
  @operation
end

Instance Method Details

#compile(context) ⇒ Object



609
610
611
612
613
614
615
# File 'lib/activefacts/cql/compiler/expression.rb', line 609

def compile(context)
  op1 = @aggregand.compile(context)
  context.vocabulary.constellation.Expression(
      :new, :expression_type => 'Unary', :operator => operator,
      :first_operand_expression => op1
  )
end

#identify_player(context) ⇒ Object



597
598
599
600
601
# File 'lib/activefacts/cql/compiler/expression.rb', line 597

def identify_player context
  @player || begin
    @player = @aggregand.player
  end
end

#inspectObject



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

def inspect; to_s; end

#operatorObject



593
594
595
# File 'lib/activefacts/cql/compiler/expression.rb', line 593

def operator
  operation
end

#refsObject



589
590
591
# File 'lib/activefacts/cql/compiler/expression.rb', line 589

def refs
  [@operation, @aggregand]
end

#to_sObject



605
606
607
# File 'lib/activefacts/cql/compiler/expression.rb', line 605

def to_s
  "AGGREGATE(#{@operation.to_s}, #{@aggregand.to_s})"
end