class CodedField

Attributes

dataSource[R]
dataSourceExists[R]
dataSourceName[R]
dataSourceRef[R]
fqName[R]
name[R]
techCode[R]
techUIdiff[R]
type[R]
uiCode[R]
uiname[R]

Public Class Methods

new(code, datasource) click to toggle source
# File lib/twb/twbcodedfield.rb, line 11
def initialize code, datasource
  # puts "\n\nCalculationField ::  %-25s  |  %s  " % [datasource.uiname, code]
  @dataSource       = datasource
  @dataSourceName   = datasource.uiname
  @dataSourceRef    = :local
  @dataSourceExists = true
  @techUIdiff       = false
  @uiname           = ''
  rawCode  = code.gsub(/^\[|\]$/,'')
  parts    = rawCode.split('].[')
  #puts "Field: #{code}  \t parts: #{parts.length} - #{parts.inspect}"
  if parts.length == 1
    @name = parts[0]
    @techCode = "[#{parts[0]}]"
    #puts "@name: #{@name}"
    if datasource.nil?
      # puts 'a'
      @uiname = @name
      @uiCode = @techCode
      @techUIdiff = false
    else # !datasource.nil?
      # puts 'b'
      #puts "b - found uiname for '#{@name}'?: #{!datasource.fieldUIName(@name).nil?} \t is:#{datasource.fieldUIName(@name)} "
      @uiname = datasource.fieldUIName(@name).nil? ? @name : datasource.fieldUIName(@name) 
      @uiCode = @uiname.nil? ? @techCode :  "[#{@uiname}]"
      @techUIdiff = !@techCode.eql?(@uiCode)
      # puts ":b #{datasource.fieldUIName(@name).nil?}  ... #{@name}  ... #{@uiname}"
      # puts "CalculationField ::       uin: %-25s | @name:%-s" % [@uiname,@name]
    end
  else # parts.length <> 1
    # puts 'c'
    rdstech   = parts[0]
    calcField = parts[1]
    @uiname   = calcField
    @dataSourceName = rdstech
    @dataSourceRef  = :remote
    @techCode = "[#{rdstech}].[#{calcField}]"
    workbook  = datasource.workbook
    @dataSource  = workbook.nil? ? nil : workbook.datasource(rdstech)
   # puts "\t  twb: #{workbook.class}  /  remoteds: #{remoteds.class}  : #{remoteds.nil? ? "<<NOT FOUND:#{rdstech}:>>" : remoteds.uiname} "
    #--
    if @dataSource.nil? || @dataSource.fieldUIName(calcField).nil?
      # puts 'd'
      @uiname     = calcField
      @uiCode     = "[<<NOT FOUND>>#{rdstech}].[#{calcField}]"
      @techUIdiff = true
      @dataSourceExists = false
    else  # !remoteds.nil?
      # puts 'e'
      @dataSourceName = @dataSource.uiname
      @uiname         = @dataSource.fieldUIName(calcField)
      @uiCode         = "[#{@dataSourceName}].[#{@uiname}]"
      @techUIdiff     = !@techCode.eql?(@uiCode)
      @dataSourceExists = true
    end
  end
  # puts "\t     dsName: #{@dataSourceName}"
  # puts "\t   @name: #{@name}"
  # puts "\t     uiname: #{@uiname}"
  @fqName = "#{@dataSourceName}::#{@uiname}"
  @type   = @dataSource.calculatedField(@uiname).nil? ? :DatabaseField : :CalculatedField
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/twb/twbcodedfield.rb, line 78
def <=>(other)
  # myName    = @uiname.nil? ? '' : @uiname
  # otherName = other.uiName.nil? ? "" : other.uiName
  # # puts "#{@uiname} / #{myName} <=>  #{otherName} / #{other.uiName}"
  # # puts "#{@uiname.nil?} // #{other.uiName.nil?}"
  # myName <=> otherName
  @fqName <=> other.fqName
end
id() click to toggle source
# File lib/twb/twbcodedfield.rb, line 74
def id
  @id ||= @id = "#{@dataSourceName}::#{@uiname}"
end