Class: Twb::CalculationField
- Inherits:
-
Object
- Object
- Twb::CalculationField
- Includes:
- Comparable, TabTool
- Defined in:
- lib/twb/fieldcalculation.rb
Instance Attribute Summary collapse
-
#dataSource ⇒ Object
readonly
Returns the value of attribute dataSource.
-
#dataSourceExists ⇒ Object
readonly
Returns the value of attribute dataSourceExists.
-
#dataSourceName ⇒ Object
readonly
Returns the value of attribute dataSourceName.
-
#dataSourceRef ⇒ Object
readonly
Returns the value of attribute dataSourceRef.
-
#fqName ⇒ Object
readonly
Returns the value of attribute fqName.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#techCode ⇒ Object
readonly
Returns the value of attribute techCode.
-
#techUIdiff ⇒ Object
readonly
Returns the value of attribute techUIdiff.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#uiCode ⇒ Object
readonly
Returns the value of attribute uiCode.
-
#uiname ⇒ Object
readonly
Returns the value of attribute uiname.
Attributes included from TabTool
#alerts, #docDir, #docfiles, #funcdoc, #licensed, #logfilename, #logger, #loglevel, #metrics, #properties, #ttdocdir, #uuid
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#id ⇒ Object
initialize.
-
#initialize(code, datasource) ⇒ CalculationField
constructor
A new instance of CalculationField.
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(code, datasource) ⇒ CalculationField
Returns a new instance of CalculationField.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/twb/fieldcalculation.rb', line 231 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 = if @dataSource.nil? :CalculatedField else @dataSource.calculatedField(@uiname).nil? ? :DatabaseField : :CalculatedField end end |
Instance Attribute Details
#dataSource ⇒ Object (readonly)
Returns the value of attribute dataSource.
227 228 229 |
# File 'lib/twb/fieldcalculation.rb', line 227 def dataSource @dataSource end |
#dataSourceExists ⇒ Object (readonly)
Returns the value of attribute dataSourceExists.
227 228 229 |
# File 'lib/twb/fieldcalculation.rb', line 227 def dataSourceExists @dataSourceExists end |
#dataSourceName ⇒ Object (readonly)
Returns the value of attribute dataSourceName.
227 228 229 |
# File 'lib/twb/fieldcalculation.rb', line 227 def dataSourceName @dataSourceName end |
#dataSourceRef ⇒ Object (readonly)
Returns the value of attribute dataSourceRef.
227 228 229 |
# File 'lib/twb/fieldcalculation.rb', line 227 def dataSourceRef @dataSourceRef end |
#fqName ⇒ Object (readonly)
Returns the value of attribute fqName.
228 229 230 |
# File 'lib/twb/fieldcalculation.rb', line 228 def fqName @fqName end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
225 226 227 |
# File 'lib/twb/fieldcalculation.rb', line 225 def name @name end |
#techCode ⇒ Object (readonly)
Returns the value of attribute techCode.
225 226 227 |
# File 'lib/twb/fieldcalculation.rb', line 225 def techCode @techCode end |
#techUIdiff ⇒ Object (readonly)
Returns the value of attribute techUIdiff.
229 230 231 |
# File 'lib/twb/fieldcalculation.rb', line 229 def techUIdiff @techUIdiff end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
228 229 230 |
# File 'lib/twb/fieldcalculation.rb', line 228 def type @type end |
#uiCode ⇒ Object (readonly)
Returns the value of attribute uiCode.
226 227 228 |
# File 'lib/twb/fieldcalculation.rb', line 226 def uiCode @uiCode end |
#uiname ⇒ Object (readonly)
Returns the value of attribute uiname.
226 227 228 |
# File 'lib/twb/fieldcalculation.rb', line 226 def uiname @uiname end |
Instance Method Details
#<=>(other) ⇒ Object
302 303 304 305 306 307 308 309 |
# File 'lib/twb/fieldcalculation.rb', line 302 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 ⇒ Object
initialize
298 299 300 |
# File 'lib/twb/fieldcalculation.rb', line 298 def id @id ||= @id = "#{@dataSourceName}::#{@uiname}" end |