Class: Locomotive::RelationalAlgebra::RefTbl

Inherits:
Leaf show all
Defined in:
lib/locomotive/relational_algebra/operators/tables/ref_table.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 Leaf

#set

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(name, attributes, keys) ⇒ RefTbl

Returns a new instance of RefTbl.



38
39
40
41
42
43
44
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 38

def initialize(name, attributes, keys)
  @name = name
  @attributes = attributes
  @keys = keys
  @name_mapping = get_name_mapping
  self.schema = get_schema
end

Dynamic Method Handling

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 7

def attributes
  @attributes
end

#keysObject (readonly)

Returns the value of attribute keys.



7
8
9
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 7

def keys
  @keys
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 7

def name
  @name
end

#name_mappingObject (readonly)

Returns the value of attribute name_mapping.



36
37
38
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 36

def name_mapping
  @name_mapping
end

Instance Method Details

#cloneObject



68
69
70
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 68

def clone
  RefTbl.new(name.clone, attributes.clone, keys.clone)
end

#xml_contentObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 50

def xml_content
  [properties do
    _keys_ do
      pos = -1
      keys.map do |k|
        key :name => k.to_xml, :position => pos += 1
      end.join
    end
  end,
  content do
    table :name => name do 
      name_mapping.collect do |new,old|
        column :name => new.to_xml, :tname => old.to_xml, :type => schema[new].first.to_xml
      end.join
    end
  end].join
end

#xml_kindObject



46
47
48
# File 'lib/locomotive/relational_algebra/operators/tables/ref_table.rb', line 46

def xml_kind
  :ref_tbl
end