class ActiveFacts::Generators::Doc::CWM::CWMDataTypeContext

Public Instance Methods

boolean_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 474
def boolean_type
  'BOOLEAN'
end
date_time_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 483
def date_time_type
  'TIMESTAMP'
end
default_char_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 487
def default_char_type
  (@unicode ? 'NATIONAL ' : '') +
  'CHARACTER'
end
default_length(data_type, type_name) click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 453
def default_length data_type, type_name
  case data_type
  when MM::DataType::TYPE_Real
    53        # IEEE Double precision floating point
  when MM::DataType::TYPE_Integer
    case type_name
    when /([a-z ]|\b)Tiny([a-z ]|\b)/i
      8
    when /([a-z ]|\b)Small([a-z ]|\b)/i,
      /([a-z ]|\b)Short([a-z ]|\b)/i
      16
    when /([a-z ]|\b)Big(INT)?([a-z ]|\b)/i
      64
    else
      32
    end
  else
    nil
  end
end
default_surrogate_length() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 497
def default_surrogate_length
  64
end
default_text_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 501
def default_text_type
  default_varchar_type
end
default_varchar_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 492
def default_varchar_type
  (@unicode ? 'NATIONAL ' : '') +
  'VARCHAR'
end
integer_ranges() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 445
def integer_ranges
  [
    ['SMALLINT', -2**15, 2**15-1],  # The standard says -10^5..10^5 (less than 16 bits)
    ['INTEGER', -2**31, 2**31-1],   # The standard says -10^10..10^10 (more than 32 bits!)
    ['BIGINT', -2**63, 2**63-1],    # The standard says -10^19..10^19 (less than 64 bits)
  ]
end
surrogate_type() click to toggle source
# File lib/activefacts/generator/doc/cwm.rb, line 478
def surrogate_type
  type_name, = choose_integer_range(0, 2**(default_surrogate_length-1)-1)
  type_name
end