Class: Turntable::ColumnDefinition

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/turntable/columndefinition.rb

Overview

A Turntable::ColumnDefinition consists of a name, its position within a Turntable::TableHeader, and, optionally, its associated type.

ColumnDefinitions are meant to be created and manipulated by a TableHeader. ColumnDefinition and its methods are not intended to be used directly by the end user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, position, type = nil) ⇒ ColumnDefinition

Creates a new ColumnDefinition. This method should not be used directly. Instead, create a new Turntable::TableHeader.



32
33
34
35
36
# File 'lib/turntable/columndefinition.rb', line 32

def initialize(name, position, type=nil)
  @name     = name
  @position = position
  @type     = type
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



26
27
28
# File 'lib/turntable/columndefinition.rb', line 26

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



27
28
29
# File 'lib/turntable/columndefinition.rb', line 27

def position
  @position
end

#typeObject (readonly)

Returns the value of attribute type.



27
28
29
# File 'lib/turntable/columndefinition.rb', line 27

def type
  @type
end

Instance Method Details

#<=>(another) ⇒ Object

A ColumnDefinition is “less than” another if its position is smaller. Likewise, a ColumnDefinition is “greater than” another if its position is greater.



22
23
24
# File 'lib/turntable/columndefinition.rb', line 22

def <=>(another)
  (self.position > another.position) ? (1) : (-1)
end