Class: Twb::ReferencedField

Inherits:
Object
  • Object
show all
Includes:
Comparable, TabTool
Defined in:
lib/twb/fieldcalculation.rb

Overview

class CalculationField

Instance Attribute Summary collapse

Attributes included from TabTool

#alerts, #docDir, #docfiles, #funcdoc, #licensed, #logfilename, #logger, #loglevel, #metrics, #properties, #ttdocdir, #uuid

Instance Method Summary collapse

Methods included from TabTool

#addDocFile, #alert, #closeDocFiles, #config, #docFile, #docFileMaxNameLen, #docfilesdoc, #docfilesdocto_s, #emit, #emitCSV, #finis, #hasConfig, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?, #loadConfig

Constructor Details

#initialize(name, datasource) ⇒ ReferencedField

Returns a new instance of ReferencedField.


344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/twb/fieldcalculation.rb', line 344

def initialize name, datasource
  # puts "\n\nReferencedField ::  ds: %-25s  |  n: %s  " % [datasource, name]
  @name             = name
  @dataSource       = datasource
  @dataSourceName   = datasource.nil? ? nil : datasource.uiname
  @dataSourceRef    = :local
  @dataSourceExists = true
  @techCode         = "[#{name}]"
  @techUIdiff       = false
  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
  @fqName = "#{@dataSourceName}::#{@uiname}"
  @type   = if @dataSource.nil?
               :CalculatedField
            else
               @dataSource.calculatedField(@uiname).nil? ? :DatabaseField : :CalculatedField
            end
end

Instance Attribute Details

#dataSourceObject (readonly)

Returns the value of attribute dataSource


340
341
342
# File 'lib/twb/fieldcalculation.rb', line 340

def dataSource
  @dataSource
end

#dataSourceExistsObject (readonly)

Returns the value of attribute dataSourceExists


340
341
342
# File 'lib/twb/fieldcalculation.rb', line 340

def dataSourceExists
  @dataSourceExists
end

#dataSourceNameObject (readonly)

Returns the value of attribute dataSourceName


340
341
342
# File 'lib/twb/fieldcalculation.rb', line 340

def dataSourceName
  @dataSourceName
end

#dataSourceRefObject (readonly)

Returns the value of attribute dataSourceRef


340
341
342
# File 'lib/twb/fieldcalculation.rb', line 340

def dataSourceRef
  @dataSourceRef
end

#fqNameObject (readonly)

Returns the value of attribute fqName


341
342
343
# File 'lib/twb/fieldcalculation.rb', line 341

def fqName
  @fqName
end

#nameObject (readonly)

Returns the value of attribute name


338
339
340
# File 'lib/twb/fieldcalculation.rb', line 338

def name
  @name
end

#techCodeObject (readonly)

Returns the value of attribute techCode


338
339
340
# File 'lib/twb/fieldcalculation.rb', line 338

def techCode
  @techCode
end

#techUIdiffObject (readonly)

Returns the value of attribute techUIdiff


342
343
344
# File 'lib/twb/fieldcalculation.rb', line 342

def techUIdiff
  @techUIdiff
end

#typeObject (readonly)

Returns the value of attribute type


341
342
343
# File 'lib/twb/fieldcalculation.rb', line 341

def type
  @type
end

#uiCodeObject (readonly)

Returns the value of attribute uiCode


339
340
341
# File 'lib/twb/fieldcalculation.rb', line 339

def uiCode
  @uiCode
end

#uinameObject (readonly)

Returns the value of attribute uiname


339
340
341
# File 'lib/twb/fieldcalculation.rb', line 339

def uiname
  @uiname
end

Instance Method Details

#<=>(other) ⇒ Object


379
380
381
382
383
384
385
386
# File 'lib/twb/fieldcalculation.rb', line 379

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

#idObject

initialize


375
376
377
# File 'lib/twb/fieldcalculation.rb', line 375

def id
  @id ||= @id = "#{@dataSourceName}::#{@uiname}"
end