Class: CodedField
- Inherits:
-
Object
- Object
- CodedField
- Includes:
- Comparable
- Defined in:
- lib/twb/twbcodedfield.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.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#id ⇒ Object
initialize.
-
#initialize(code, datasource) ⇒ CodedField
constructor
A new instance of CodedField.
Constructor Details
#initialize(code, datasource) ⇒ CodedField
Returns a new instance of CodedField.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# 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 |
Instance Attribute Details
#dataSource ⇒ Object (readonly)
Returns the value of attribute dataSource.
7 8 9 |
# File 'lib/twb/twbcodedfield.rb', line 7 def dataSource @dataSource end |
#dataSourceExists ⇒ Object (readonly)
Returns the value of attribute dataSourceExists.
7 8 9 |
# File 'lib/twb/twbcodedfield.rb', line 7 def dataSourceExists @dataSourceExists end |
#dataSourceName ⇒ Object (readonly)
Returns the value of attribute dataSourceName.
7 8 9 |
# File 'lib/twb/twbcodedfield.rb', line 7 def dataSourceName @dataSourceName end |
#dataSourceRef ⇒ Object (readonly)
Returns the value of attribute dataSourceRef.
7 8 9 |
# File 'lib/twb/twbcodedfield.rb', line 7 def dataSourceRef @dataSourceRef end |
#fqName ⇒ Object (readonly)
Returns the value of attribute fqName.
8 9 10 |
# File 'lib/twb/twbcodedfield.rb', line 8 def fqName @fqName end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/twb/twbcodedfield.rb', line 5 def name @name end |
#techCode ⇒ Object (readonly)
Returns the value of attribute techCode.
5 6 7 |
# File 'lib/twb/twbcodedfield.rb', line 5 def techCode @techCode end |
#techUIdiff ⇒ Object (readonly)
Returns the value of attribute techUIdiff.
9 10 11 |
# File 'lib/twb/twbcodedfield.rb', line 9 def techUIdiff @techUIdiff end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/twb/twbcodedfield.rb', line 8 def type @type end |
#uiCode ⇒ Object (readonly)
Returns the value of attribute uiCode.
6 7 8 |
# File 'lib/twb/twbcodedfield.rb', line 6 def uiCode @uiCode end |
#uiname ⇒ Object (readonly)
Returns the value of attribute uiname.
6 7 8 |
# File 'lib/twb/twbcodedfield.rb', line 6 def uiname @uiname end |
Instance Method Details
#<=>(other) ⇒ Object
78 79 80 81 82 83 84 85 |
# 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 ⇒ Object
initialize
74 75 76 |
# File 'lib/twb/twbcodedfield.rb', line 74 def id @id ||= @id = "#{@dataSourceName}::#{@uiname}" end |