Class: Mysql::Partitioner::Partition::Range

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql/partitioner/partition/range.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(less_than, name = nil) ⇒ Range

Returns a new instance of Range.



7
8
9
10
11
12
13
# File 'lib/mysql/partitioner/partition/range.rb', line 7

def initialize(less_than, name=nil)
  self.less_than = less_than == "MAXVALUE" ? Float::MAX : less_than.to_i
  if name == nil then
    name = self.build_name
  end
  self.name = name
end

Instance Attribute Details

#less_thanObject

Returns the value of attribute less_than.



5
6
7
# File 'lib/mysql/partitioner/partition/range.rb', line 5

def less_than
  @less_than
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mysql/partitioner/partition/range.rb', line 5

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
# File 'lib/mysql/partitioner/partition/range.rb', line 31

def ==(other)
  other.instance_of?(self.class) && other.name == self.name
end

#bounded?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mysql/partitioner/partition/range.rb', line 15

def bounded?
  self.less_than < Float::MAX
end

#build_nameObject



19
20
21
# File 'lib/mysql/partitioner/partition/range.rb', line 19

def build_name()
  "p" + self.less_than.to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/mysql/partitioner/partition/range.rb', line 27

def eql?(other)
  self == other
end

#hashObject



35
36
37
# File 'lib/mysql/partitioner/partition/range.rb', line 35

def hash
  self.name.hash
end

#to_partition_defObject



23
24
25
# File 'lib/mysql/partitioner/partition/range.rb', line 23

def to_partition_def
  "PARTITION #{self.name} VALUES LESS THAN (#{self.less_than})"
end