Class: Locomotive::RelationalAlgebra::Select

Inherits:
Unary show all
Defined in:
lib/locomotive/relational_algebra/operators/filter/select.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_kind, #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, item) ⇒ Select

Returns a new instance of Select.



8
9
10
11
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 8

def initialize(op,  item)
  self.item = item
  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

#itemObject

Returns the value of attribute item.



6
7
8
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 6

def item
  @item
end

Instance Method Details

#child=(op) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 13

def child=(op)
  unless op.schema.attributes?([item])
    raise CorruptedSchema,
          "Schema #{op.schema.attributes} does not " \
          "contain all attributes of #{item}."
  end
  
  unless op.schema[item].member? RBool.instance
    raise CorruptedSchema,
          "#{item}(#{op.schema[item]}) doesn have the type Boolean."
  end
    
  self.schema = op.schema.clone
  super(op)
end

#cloneObject



35
36
37
38
39
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 35

def clone
  Select.new(
    self.child.clone,
    self.item.clone)
end

#set(var, plan) ⇒ Object



41
42
43
44
45
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 41

def set(var,plan)
  Select.new(
    child.set(var,plan),
    item.clone)
end

#xml_contentObject



29
30
31
32
33
# File 'lib/locomotive/relational_algebra/operators/filter/select.rb', line 29

def xml_content
  content do
    column :name => item.to_xml, :new => false
  end
end