Class: Locomotive::RelationalAlgebra::Cast

Inherits:
Unary show all
Defined in:
lib/locomotive/relational_algebra/operators/typeing/cast.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, res, item, type) ⇒ Cast

Returns a new instance of Cast.



15
16
17
18
19
20
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 15

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



8
9
10
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 8

def item
  @item
end

#resObject

Returns the value of attribute res.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 8

def res
  @res
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 8

def type
  @type
end

Instance Method Details

#child=(op) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 22

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

#cloneObject



40
41
42
43
44
45
46
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 40

def clone
  Cast.new(
    child.clone,
    res.clone,
    item.clone,
    type.clone)
end

#set(var, plan) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 48

def set(var,plan)
  Cast.new(
    child.set(var,plan),
    res.clone,
    item.clone,
    type.clone)
end

#xml_contentObject



32
33
34
35
36
37
38
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 32

def xml_content
  content do
    [column(:name => res.to_xml, :new => true),
     column(:name => item.to_xml, :new => false),
     _type_(:name => type.to_xml)].join
  end
end