Class: Axiom::Relation::Base

Inherits:
Axiom::Relation show all
Defined in:
lib/axiom/relation/base.rb

Overview

A class that represents a base relation

Instance Attribute Summary collapse

Attributes inherited from Axiom::Relation

#header

Instance Method Summary collapse

Methods inherited from Axiom::Relation

#[], #directions, #each, #empty?, #include?, #materialize, #materialized?, new, #replace

Methods included from Visitable

#accept

Constructor Details

#initialize(name, header, tuples = Empty::ZERO_TUPLE) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a base relation

Parameters:

  • name (#to_sym)

    the relation name

  • header (Header, #to_ary)

    the relation header

  • tuples (Enumerable) (defaults to: Empty::ZERO_TUPLE)

    the relation tuples



32
33
34
35
# File 'lib/axiom/relation/base.rb', line 32

def initialize(name, header, tuples = Empty::ZERO_TUPLE)
  super(header, tuples)
  @name = name.to_sym
end

Instance Attribute Details

#nameSymbol (readonly)

The base relation name

Examples:

name = base.name

Returns:

  • (Symbol)


18
19
20
# File 'lib/axiom/relation/base.rb', line 18

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean

Compare the base relation with other relation for equivalency

Examples:

base == other  # => true or false

Parameters:

  • other (Relation)

    the other relation to compare with

Returns:

  • (Boolean)


48
49
50
# File 'lib/axiom/relation/base.rb', line 48

def ==(other)
  super && (!other.respond_to?(:name) || name == other.name)
end