Class: Twb::CalculationField
- Inherits:
-
Object
- Object
- Twb::CalculationField
- Includes:
- Comparable
- 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.
-
#dataSourceRef ⇒ Object
readonly
Returns the value of attribute dataSourceRef.
-
#fqName ⇒ Object
readonly
Returns the value of attribute fqName.
-
#techCode ⇒ Object
readonly
Returns the value of attribute techCode.
-
#techName ⇒ Object
readonly
Returns the value of attribute techName.
-
#techUIdiff ⇒ Object
readonly
Returns the value of attribute techUIdiff.
-
#uiCode ⇒ Object
readonly
Returns the value of attribute uiCode.
-
#uiName ⇒ Object
readonly
Returns the value of attribute uiName.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
initialize.
-
#initialize(code, datasource, workbook) ⇒ CalculationField
constructor
A new instance of CalculationField.
Constructor Details
#initialize(code, datasource, workbook) ⇒ CalculationField
Returns a new instance of CalculationField.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/twb/fieldcalculation.rb', line 203 def initialize code, datasource, workbook # puts "\nCalculationField <= \n\t #{code}" @dataSource = datasource.uiname @dataSourceRef = :local @dataSourceExists = true @techUIdiff = false @uiName = '' rawCode = code.gsub(/^\[|\]$/,'') parts = rawCode.split('].[') # puts "\n\nField: #{code} \t parts: #{parts.length} - #{parts.inspect}" if parts.length == 1 @techName = parts[0] @techCode = "[#{parts[0]}]" if datasource.nil? @uiName = @techName @uiCode = @techCode @techUIdiff = false else # !datasource.nil? # puts "#{@techName} \t:: #{datasource.fieldUIName(@techName).nil?} \t:: #{datasource.fieldUIName(@techName)} " @uiName = datasource.fieldUIName(@techName).nil? ? @techName : datasource.fieldUIName(@techName) @uiCode = @uiName.nil? ? @techCode : "[#{@uiName}]" @techUIdiff = !@techCode.eql?(@uiCode) end else # parts.length <> 1 rdstech = parts[0] calcField = parts[1] @uiName = calcField @dataSource = rdstech @dataSourceRef = :remote @techCode = "[#{rdstech}].[#{calcField}]" workbook = datasource.workbook remoteds = workbook.nil? ? nil : workbook.datasource(rdstech) # puts "\t twb: #{workbook.class} / remoteds: #{remoteds.class} : #{remoteds.nil? ? "<<NOT FOUND:#{rdstech}:>>" : remoteds.uiname} " #-- if remoteds.nil? || remoteds.fieldUIName(calcField).nil? @uiName = calcField @uiCode = "[<<NOT FOUND>>#{rdstech}].[#{calcField}]" @techUIdiff = true @dataSourceExists = false else !remoteds.nil? @dataSource = remoteds.uiname @uiName = remoteds.fieldUIName(calcField) @uiCode = "[#{@dataSource}].[#{@uiName}]" @techUIdiff = !@techCode.eql?(@uiCode) @dataSourceExists = true end end @fqName = "#{@dataSource}::#{@uiName}" end |
Instance Attribute Details
#dataSource ⇒ Object (readonly)
Returns the value of attribute dataSource.
199 200 201 |
# File 'lib/twb/fieldcalculation.rb', line 199 def dataSource @dataSource end |
#dataSourceExists ⇒ Object (readonly)
Returns the value of attribute dataSourceExists.
199 200 201 |
# File 'lib/twb/fieldcalculation.rb', line 199 def dataSourceExists @dataSourceExists end |
#dataSourceRef ⇒ Object (readonly)
Returns the value of attribute dataSourceRef.
199 200 201 |
# File 'lib/twb/fieldcalculation.rb', line 199 def dataSourceRef @dataSourceRef end |
#fqName ⇒ Object (readonly)
Returns the value of attribute fqName.
200 201 202 |
# File 'lib/twb/fieldcalculation.rb', line 200 def fqName @fqName end |
#techCode ⇒ Object (readonly)
Returns the value of attribute techCode.
197 198 199 |
# File 'lib/twb/fieldcalculation.rb', line 197 def techCode @techCode end |
#techName ⇒ Object (readonly)
Returns the value of attribute techName.
197 198 199 |
# File 'lib/twb/fieldcalculation.rb', line 197 def techName @techName end |
#techUIdiff ⇒ Object (readonly)
Returns the value of attribute techUIdiff.
201 202 203 |
# File 'lib/twb/fieldcalculation.rb', line 201 def techUIdiff @techUIdiff end |
#uiCode ⇒ Object (readonly)
Returns the value of attribute uiCode.
198 199 200 |
# File 'lib/twb/fieldcalculation.rb', line 198 def uiCode @uiCode end |
#uiName ⇒ Object (readonly)
Returns the value of attribute uiName.
198 199 200 |
# File 'lib/twb/fieldcalculation.rb', line 198 def uiName @uiName end |
Instance Method Details
#<=>(other) ⇒ Object
initialize
253 254 255 256 257 258 259 260 |
# File 'lib/twb/fieldcalculation.rb', line 253 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 |