Class: Locomotive::RelationalAlgebra::Function

Inherits:
Unary show all
Defined in:
lib/locomotive/relational_algebra/operators/builtins/function.rb

Instance Attribute Summary collapse

Attributes inherited from Operator

#schema

Attributes included from AstHelpers::AstNode

#kind, #left_child, #owner, #right_child, #value

Instance Method Summary collapse

Methods inherited from Operator

#bound, #free, #to_xml, #xml_schema

Methods included from XML

included, #quote, #to_xml

Methods included from AstHelpers::Annotations

#method_missing, #respond_to?

Methods included from AstHelpers::AstNode

#has_left_child?, #has_right_child?, #is_leaf?, #traverse, #traverse_strategy=

Constructor Details

#initialize(op, operator, res, items) ⇒ Function

Returns a new instance of Function.



16
17
18
19
20
21
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 16

def initialize(op, operator, res, items)
  self.operator,
  self.res,
  self.items = operator, res, items
  super(op)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Locomotive::AstHelpers::Annotations

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 8

def items
  @items
end

#operatorObject

Returns the value of attribute operator.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 8

def operator
  @operator
end

#resObject

Returns the value of attribute res.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 8

def res
  @res
end

Instance Method Details

#child=(op) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 23

def child=(op)
  unless op.schema.attributes?(self.items)
    raise CorruptedSchema,
          "Schema #{op.schema.attributes} does not " \
          "contain all attributes of #{items}."
  end
    
  self.schema = op.schema +
                  Schema.new( { res => op.schema[items.first] } )
  super(op)
end

#cloneObject



51
52
53
54
55
56
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 51

def clone
  Function.new(child.clone,
               operator.clone,
               res.clone,
               items.clone)
end

#set(var, plan) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 58

def set(var, plan)
  Function.new(
    child.set(var,plan),
    operator.clone,
    res.clone,
    items.clone) 
end

#xml_contentObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 39

def xml_content
  content do
    [
     kind(:name => operator.to_xml),
     column(:name => res.to_xml, :new => true),
     items.collect do |it|
       column :name => it.to_xml, :new => false
     end.join
    ].join
  end
end

#xml_kindObject



35
36
37
# File 'lib/locomotive/relational_algebra/operators/builtins/function.rb', line 35

def xml_kind
  :fun
end