Class: Locomotive::RelationalAlgebra::Cast
- Inherits:
-
Unary
- Object
- RelAlgAstNode
- Operator
- Unary
- Locomotive::RelationalAlgebra::Cast
- Defined in:
- lib/locomotive/relational_algebra/operators/typeing/cast.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#res ⇒ Object
Returns the value of attribute res.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Operator
Attributes included from AstHelpers::AstNode
#kind, #left_child, #owner, #right_child, #value
Instance Method Summary collapse
- #child=(op) ⇒ Object
- #clone ⇒ Object
-
#initialize(op, res, item, type) ⇒ Cast
constructor
A new instance of Cast.
- #set(var, plan) ⇒ Object
- #xml_content ⇒ Object
Methods inherited from Operator
#bound, #free, #to_xml, #xml_kind, #xml_schema
Methods included from XML
Methods included from AstHelpers::Annotations
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
#item ⇒ Object
Returns the value of attribute item.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 8 def item @item end |
#res ⇒ Object
Returns the value of attribute res.
8 9 10 |
# File 'lib/locomotive/relational_algebra/operators/typeing/cast.rb', line 8 def res @res end |
#type ⇒ Object
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 |
#clone ⇒ Object
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_content ⇒ Object
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 |