Class: Alf::Algebra::Operand::Fake

Inherits:
Object
  • Object
show all
Includes:
Alf::Algebra::Operand
Defined in:
lib/alf/algebra/operand/fake.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Alf::Algebra::Operand

#attr_list, coerce, #resulting_type, #to_ascii_tree, #to_relation, #type_check

Constructor Details

#initialize(connection = nil, cog = nil) ⇒ Fake

Returns a new instance of Fake


7
8
9
10
11
# File 'lib/alf/algebra/operand/fake.rb', line 7

def initialize(connection = nil, cog = nil)
  @connection = connection
  @attributes = {}
  @cog = cog
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection


12
13
14
# File 'lib/alf/algebra/operand/fake.rb', line 12

def connection
  @connection
end

Instance Method Details

#eachObject


30
31
# File 'lib/alf/algebra/operand/fake.rb', line 30

def each
end

#headingObject


37
38
39
# File 'lib/alf/algebra/operand/fake.rb', line 37

def heading
  @attributes[:heading] || (connection && connection.heading(name)) || super
end

#keysObject


41
42
43
# File 'lib/alf/algebra/operand/fake.rb', line 41

def keys
  @attributes[:keys] || Keys::EMPTY
end

#nameObject


33
34
35
# File 'lib/alf/algebra/operand/fake.rb', line 33

def name
  @attributes[:name] || "a_fake_operand"
end

#to_cog(plan = nil) ⇒ Object


53
54
55
# File 'lib/alf/algebra/operand/fake.rb', line 53

def to_cog(plan = nil)
  @cog || Engine::Leaf.new([], self)
end

#to_lispyObject


61
62
63
# File 'lib/alf/algebra/operand/fake.rb', line 61

def to_lispy
  name
end

#to_relvarObject


45
46
47
48
49
50
51
# File 'lib/alf/algebra/operand/fake.rb', line 45

def to_relvar
  if connection && name
    Operand::Named.new(name, connection).to_relvar
  else
    Relvar::Fake.new(self, heading)
  end
end

#to_sObject


57
58
59
# File 'lib/alf/algebra/operand/fake.rb', line 57

def to_s
  name.to_s
end

#with_connection(conn) ⇒ Object


14
15
16
# File 'lib/alf/algebra/operand/fake.rb', line 14

def with_connection(conn)
  dup.tap{|d| d.connection = conn }
end

#with_heading(h) ⇒ Object


18
19
20
# File 'lib/alf/algebra/operand/fake.rb', line 18

def with_heading(h)
  dup.set!(:heading => Alf::Heading.coerce(h))
end

#with_keys(*keys) ⇒ Object


22
23
24
# File 'lib/alf/algebra/operand/fake.rb', line 22

def with_keys(*keys)
  dup.set!(:keys => Alf::Keys.coerce(keys))
end

#with_name(name) ⇒ Object


26
27
28
# File 'lib/alf/algebra/operand/fake.rb', line 26

def with_name(name)
  dup.set!(:name => name.to_sym)
end