Class: ActiveFacts::CQL::Compiler::Literal
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::Literal
- Defined in:
- lib/activefacts/cql/compiler/expression.rb
Instance Attribute Summary collapse
-
#clause ⇒ Object
Returns the value of attribute clause.
-
#leading_adjective ⇒ Object
readonly
Returns the value of attribute leading_adjective.
-
#literal ⇒ Object
Returns the value of attribute literal.
-
#objectification_of ⇒ Object
readonly
Returns the value of attribute objectification_of.
-
#role ⇒ Object
Returns the value of attribute role.
-
#role_ref ⇒ Object
Returns the value of attribute role_ref.
-
#trailing_adjective ⇒ Object
readonly
Returns the value of attribute trailing_adjective.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#value_constraint ⇒ Object
readonly
Returns the value of attribute value_constraint.
Instance Method Summary collapse
- #bind(context) ⇒ Object
- #binding ⇒ Object
- #compile(context) ⇒ Object
- #identify_other_players(context) ⇒ Object
- #identify_player(context) ⇒ Object
- #identify_players_with_role_name(context) ⇒ Object
-
#initialize(literal, unit) ⇒ Literal
constructor
A new instance of Literal.
- #inspect ⇒ Object
- #nested_clauses ⇒ Object
- #player ⇒ Object
-
#role_name ⇒ Object
Stubs:.
- #to_s ⇒ Object
Constructor Details
#initialize(literal, unit) ⇒ Literal
Returns a new instance of Literal.
622 623 624 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 622 def initialize literal, unit @literal, @unit = literal, unit end |
Instance Attribute Details
#clause ⇒ Object
Returns the value of attribute clause.
619 620 621 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 619 def clause @clause end |
#leading_adjective ⇒ Object (readonly)
Returns the value of attribute leading_adjective.
620 621 622 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 620 def leading_adjective @leading_adjective end |
#literal ⇒ Object
Returns the value of attribute literal.
619 620 621 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 619 def literal @literal end |
#objectification_of ⇒ Object (readonly)
Returns the value of attribute objectification_of.
620 621 622 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 620 def objectification_of @objectification_of end |
#role ⇒ Object
Returns the value of attribute role.
619 620 621 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 619 def role @role end |
#role_ref ⇒ Object
Returns the value of attribute role_ref.
619 620 621 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 619 def role_ref @role_ref end |
#trailing_adjective ⇒ Object (readonly)
Returns the value of attribute trailing_adjective.
620 621 622 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 620 def trailing_adjective @trailing_adjective end |
#unit ⇒ Object
Returns the value of attribute unit.
619 620 621 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 619 def unit @unit end |
#value_constraint ⇒ Object (readonly)
Returns the value of attribute value_constraint.
620 621 622 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 620 def value_constraint @value_constraint end |
Instance Method Details
#bind(context) ⇒ Object
662 663 664 665 666 667 668 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 662 def bind context @binding || begin key = "#{@player.name} #{@literal}" @binding = (context.bindings[key] ||= Binding.new(@player)) @binding.refs << self end end |
#binding ⇒ Object
670 671 672 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 670 def binding @binding end |
#compile(context) ⇒ Object
674 675 676 677 678 679 680 681 682 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 674 def compile(context) literal_string = case @literal when String; "'#{@literal.to_s}'" else @literal.to_s end context.vocabulary.constellation.Expression( :new, :expression_type => 'Literal', :literal_string => literal_string ) end |
#identify_other_players(context) ⇒ Object
644 645 646 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 644 def identify_other_players(context) identify_player context end |
#identify_player(context) ⇒ Object
648 649 650 651 652 653 654 655 656 657 658 659 660 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 648 def identify_player context @player || begin player_name = case @literal when String; 'String' when Float; 'Real' when Numeric; 'Integer' when TrueClass, FalseClass; 'Boolean' end v = context.vocabulary @player = v.constellation.ValueType(v, player_name) end end |
#identify_players_with_role_name(context) ⇒ Object
640 641 642 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 640 def identify_players_with_role_name(context) # Nothing to do here, move along end |
#inspect ⇒ Object
630 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 630 def inspect; to_s; end |
#nested_clauses ⇒ Object
628 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 628 def nested_clauses; nil; end |
#player ⇒ Object
636 637 638 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 636 def player @player end |
#role_name ⇒ Object
Stubs:
627 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 627 def role_name; nil; end |
#to_s ⇒ Object
632 633 634 |
# File 'lib/activefacts/cql/compiler/expression.rb', line 632 def to_s unit ? "(#{@literal.to_s} in #{unit.to_s})" : @literal.to_s end |