RBase::Columns::NumberColumn

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/rbase/columns.rb, line 114
def initialize(name, options = {})
  size = options[:size] || 18
  size = 18 if size > 18
  
  super name, options.merge(:size => size)
end

Public Instance Methods

float?() click to toggle source
# File lib/rbase/columns.rb, line 146
def float?
  decimal && decimal != 0
end
inspect() click to toggle source
# File lib/rbase/columns.rb, line 138
def inspect
  if float?
    "#{name}(decimal)"
  else
    "#{name}(integer)"
  end
end
pack(value) click to toggle source
# File lib/rbase/columns.rb, line 121
def pack(value)
  if value
    if float?
      [format("%#{size-decimal-1}.#{decimal}f", value)].pack("A#{size}")
    else
      [format("%#{size}d", value)].pack("A#{size}")
    end
  else
    " "*size
  end
end
unpack(data) click to toggle source
# File lib/rbase/columns.rb, line 133
def unpack(data)
  return nil if data.strip == ''
  data.rstrip.to_i
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.