Class: Locomotive::RelationalAlgebra::Attribute

Inherits:
GenericAttribute show all
Includes:
HashKeys
Defined in:
lib/locomotive/relational_algebra/attributes.rb

Defined Under Namespace

Modules: HashKeys

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashKeys

#eql?, #hash

Constructor Details

#initialize(name) ⇒ Attribute

Returns a new instance of Attribute.



121
122
123
# File 'lib/locomotive/relational_algebra/attributes.rb', line 121

def initialize(name)
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



119
120
121
# File 'lib/locomotive/relational_algebra/attributes.rb', line 119

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object

Equality for attributes is defined over their class their name



127
128
129
130
# File 'lib/locomotive/relational_algebra/attributes.rb', line 127

def ==(other)
  self.class == other.class and
  self.name == other.name
end

#cloneObject



160
161
162
163
# File 'lib/locomotive/relational_algebra/attributes.rb', line 160

def clone
  # an attributes contains only an id
  Attribute.new(name)
end

#inspectObject



156
157
158
# File 'lib/locomotive/relational_algebra/attributes.rb', line 156

def inspect
  "<#{self.class.to_s.split('::').last} name:#{name}>"
end

#to_xmlObject



150
151
152
153
# File 'lib/locomotive/relational_algebra/attributes.rb', line 150

def to_xml
  # Be careful of classes that are nested in modules
  name
end