Class: Alf::Algebra::Operand::Named
Instance Attribute Summary collapse
Instance Method Summary
collapse
#attr_list, coerce, #resulting_type, #to_ascii_tree, #to_relation
Constructor Details
#initialize(name, connection = nil) ⇒ Named
7
8
9
10
|
# File 'lib/alf/algebra/operand/named.rb', line 7
def initialize(name, connection = nil)
@name = name
@connection = connection
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection
11
12
13
|
# File 'lib/alf/algebra/operand/named.rb', line 11
def connection
@connection
end
|
#name ⇒ Object
Returns the value of attribute name
11
12
13
|
# File 'lib/alf/algebra/operand/named.rb', line 11
def name
@name
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
35
36
37
38
39
|
# File 'lib/alf/algebra/operand/named.rb', line 35
def ==(other)
super || (other.is_a?(Named) &&
other.name==name &&
other.connection == connection)
end
|
#connection! ⇒ Object
13
14
15
16
|
# File 'lib/alf/algebra/operand/named.rb', line 13
def connection!
raise UnboundError, "Expression not bound `#{name}`" unless connection
connection
end
|
#hash ⇒ Object
31
32
33
|
# File 'lib/alf/algebra/operand/named.rb', line 31
def hash
@hash ||= name.hash + 37*connection.hash
end
|
#heading ⇒ Object
27
28
29
|
# File 'lib/alf/algebra/operand/named.rb', line 27
def heading
connection!.heading(name)
end
|
#inspect ⇒ Object
54
55
56
|
# File 'lib/alf/algebra/operand/named.rb', line 54
def inspect
"Operand::Named(#{name.inspect})"
end
|
#keys ⇒ Object
23
24
25
|
# File 'lib/alf/algebra/operand/named.rb', line 23
def keys
connection!.keys(name)
end
|
#to_cog(plan = Alf::Compiler::Plan.new) ⇒ Object
42
43
44
|
# File 'lib/alf/algebra/operand/named.rb', line 42
def to_cog(plan = Alf::Compiler::Plan.new)
connection!.cog(plan, self)
end
|
#to_lispy ⇒ Object
58
59
60
|
# File 'lib/alf/algebra/operand/named.rb', line 58
def to_lispy
name.to_s
end
|
#to_relvar ⇒ Object
46
47
48
|
# File 'lib/alf/algebra/operand/named.rb', line 46
def to_relvar
Relvar::Base.new(self)
end
|
#to_s ⇒ Object
50
51
52
|
# File 'lib/alf/algebra/operand/named.rb', line 50
def to_s
name.to_s
end
|
#type_check(options = {strict: false}) ⇒ Object
18
19
20
21
|
# File 'lib/alf/algebra/operand/named.rb', line 18
def type_check(options = {strict: false})
return heading if connection!.knows?(name)
raise TypeCheckError, "No such relvar `#{name}`"
end
|