Class: Locomotive::RelationalAlgebra::ConstAttribute
- Inherits:
-
GenericAttribute
- Object
- GenericAttribute
- Locomotive::RelationalAlgebra::ConstAttribute
- Includes:
- HashKeys
- Defined in:
- lib/locomotive/relational_algebra/attributes.rb
Defined Under Namespace
Modules: HashKeys
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Equality for attributes is defined over their class and id.
- #clone ⇒ Object
- #inc(val = 1) ⇒ Object
-
#initialize(id = 0) ⇒ ConstAttribute
constructor
A new instance of ConstAttribute.
- #inspect ⇒ Object
- #to_xml ⇒ Object
Methods included from HashKeys
Constructor Details
#initialize(id = 0) ⇒ ConstAttribute
Returns a new instance of ConstAttribute.
30 31 32 33 34 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 30 def initialize(id=0) raise AbstractClassError, "#{self.class} is an abstract class" if self.class == ConstAttribute self.id = id end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
28 29 30 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 28 def id @id end |
Instance Method Details
#==(other) ⇒ Object
Equality for attributes is defined over their class and id
48 49 50 51 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 48 def ==(other) self.class == other.class and self.id == other.id end |
#clone ⇒ Object
71 72 73 74 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 71 def clone # an attributes contains only an id self.class.new(id) end |
#inc(val = 1) ⇒ Object
37 38 39 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 37 def inc(val=1) self.class.new(self.id + val) end |
#inspect ⇒ Object
76 77 78 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 76 def inspect "<#{self.class.to_s.split('::').last} #{id}>" end |
#to_xml ⇒ Object
41 42 43 44 |
# File 'lib/locomotive/relational_algebra/attributes.rb', line 41 def to_xml # Be careful of classes that are nested in modules "#{self.class.to_s.split("::").last.downcase}#{nth id}".to_sym end |