Module: Alf::Compiler::Cog

Extended by:
Forwardable
Included in:
Engine::Cog
Defined in:
lib/alf/compiler/cog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#compilerObject (readonly)

Returns the value of attribute compiler


11
12
13
# File 'lib/alf/compiler/cog.rb', line 11

def compiler
  @compiler
end

#exprObject (readonly)

Returns the value of attribute expr


10
11
12
# File 'lib/alf/compiler/cog.rb', line 10

def expr
  @expr
end

Instance Method Details

#cog_ordersObject


17
18
19
# File 'lib/alf/compiler/cog.rb', line 17

def cog_orders
  []
end

#initialize(expr, compiler) ⇒ Object


6
7
8
9
# File 'lib/alf/compiler/cog.rb', line 6

def initialize(expr, compiler)
  @expr = expr
  @compiler = compiler
end

#orderedby?(order) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/alf/compiler/cog.rb', line 21

def orderedby?(order)
  cog_orders.any?{|o| order <= o }
end

#relation_typeObject


33
34
35
# File 'lib/alf/compiler/cog.rb', line 33

def relation_type
  @relation_type ||= Relation[heading]
end

#to_ascii_treeObject


29
30
31
# File 'lib/alf/compiler/cog.rb', line 29

def to_ascii_tree
  Support::Tree.new(self).to_text
end

#to_cogObject


25
26
27
# File 'lib/alf/compiler/cog.rb', line 25

def to_cog
  self
end

#to_relationObject


37
38
39
40
41
42
# File 'lib/alf/compiler/cog.rb', line 37

def to_relation
  raise NotSupportedError unless expr
  relation_type.new(each)
rescue NotSupportedError
  Relation.coerce(each)
end