class DBF::Column
Constants
- TYPE_CAST_CLASS
Attributes
decimal[R]
length[R]
name[R]
table[R]
type[R]
Public Class Methods
new(table, name, type, length, decimal)
click to toggle source
Initialize a new DBF::Column
@param table [String] @param name [String] @param type [String] @param length [Integer] @param decimal [Integer]
# File lib/dbf/column.rb, line 37 def initialize(table, name, type, length, decimal) @table = table @name = clean(name) @type = type @length = length @decimal = decimal @version = table.version @encoding = table.encoding validate_length validate_name end
Public Instance Methods
memo?()
click to toggle source
Returns true if the column is a memo
@return [Boolean]
# File lib/dbf/column.rb, line 53 def memo? @memo ||= type == 'M' end
to_hash()
click to toggle source
Returns a Hash with :name, :type, :length, and :decimal keys
@return [Hash]
# File lib/dbf/column.rb, line 60 def to_hash {name: name, type: type, length: length, decimal: decimal} end
underscored_name()
click to toggle source
Underscored name
This is the column name converted to underscore format. For example, MyColumn will be returned as my_column.
@return [String]
# File lib/dbf/column.rb, line 70 def underscored_name @underscored_name ||= begin name.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end end