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.



340
341
342
343
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
# File 'lib/twb/fieldcalculation.rb', line 340

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.



336
337
338
# File 'lib/twb/fieldcalculation.rb', line 336

def dataSource
  @dataSource
end

#dataSourceExistsObject (readonly)

Returns the value of attribute dataSourceExists.



336
337
338
# File 'lib/twb/fieldcalculation.rb', line 336

def dataSourceExists
  @dataSourceExists
end

#dataSourceNameObject (readonly)

Returns the value of attribute dataSourceName.



336
337
338
# File 'lib/twb/fieldcalculation.rb', line 336

def dataSourceName
  @dataSourceName
end

#dataSourceRefObject (readonly)

Returns the value of attribute dataSourceRef.



336
337
338
# File 'lib/twb/fieldcalculation.rb', line 336

def dataSourceRef
  @dataSourceRef
end

#fqNameObject (readonly)

Returns the value of attribute fqName.



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

def fqName
  @fqName
end

#nameObject (readonly)

Returns the value of attribute name.



334
335
336
# File 'lib/twb/fieldcalculation.rb', line 334

def name
  @name
end

#techCodeObject (readonly)

Returns the value of attribute techCode.



334
335
336
# File 'lib/twb/fieldcalculation.rb', line 334

def techCode
  @techCode
end

#techUIdiffObject (readonly)

Returns the value of attribute techUIdiff.



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

def techUIdiff
  @techUIdiff
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#uiCodeObject (readonly)

Returns the value of attribute uiCode.



335
336
337
# File 'lib/twb/fieldcalculation.rb', line 335

def uiCode
  @uiCode
end

#uinameObject (readonly)

Returns the value of attribute uiname.



335
336
337
# File 'lib/twb/fieldcalculation.rb', line 335

def uiname
  @uiname
end

Instance Method Details

#<=>(other) ⇒ Object



375
376
377
378
379
380
381
382
# File 'lib/twb/fieldcalculation.rb', line 375

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



371
372
373
# File 'lib/twb/fieldcalculation.rb', line 371

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