Class: Twb::CodedField
- Inherits:
-
Object
- Object
- Twb::CodedField
- Includes:
- Comparable
- Defined in:
- lib/twb/codedfield.rb
Instance Attribute Summary collapse
-
#dataSource ⇒ Object
readonly
Returns the value of attribute dataSource.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rawCode ⇒ Object
readonly
Returns the value of attribute rawCode.
-
#techCode ⇒ Object
readonly
Returns the value of attribute techCode.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #id ⇒ Object
-
#initialize(code) ⇒ CodedField
constructor
A new instance of CodedField.
-
#parseField(str) ⇒ Object
initialize.
- #to_s ⇒ Object
Constructor Details
#initialize(code) ⇒ CodedField
Returns a new instance of CodedField.
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 |
# File 'lib/twb/codedfield.rb', line 29 def initialize code # puts "...CodedField :: #{code}" @rawCode = code trimmed = code.gsub(/^['"]|['"]$/,'').gsub(/^\[|\]$/,'').gsub(/:[0-9]+$/,'') # puts " trimmed :: #{trimmed}" parts = trimmed.split('].[') #puts "Field: #{code} parts: #{parts.length} - #{parts.inspect}" #puts " p1: #{parts[0]}" #puts " p2: #{parts[1]}" if parts.length == 1 #puts '==1' @name = parts[0] @techCode = "[#{@name}]" elsif # parts.length <> 1 #puts '<>1' #puts "p[0]: #{parts[0]}" #puts "p[1]: #{parts[1]}" @dataSource = parts[0] fldName = parts[1] if fldName.start_with?(':') && fldName.count(':') == 1 @name = fldName else parseField fldName end @techCode = "[#{@dataSource}].[#{@name}]" end end |
Instance Attribute Details
#dataSource ⇒ Object (readonly)
Returns the value of attribute dataSource
26 27 28 |
# File 'lib/twb/codedfield.rb', line 26 def dataSource @dataSource end |
#function ⇒ Object (readonly)
Returns the value of attribute function
27 28 29 |
# File 'lib/twb/codedfield.rb', line 27 def function @function end |
#name ⇒ Object (readonly)
Returns the value of attribute name
27 28 29 |
# File 'lib/twb/codedfield.rb', line 27 def name @name end |
#rawCode ⇒ Object (readonly)
Returns the value of attribute rawCode
27 28 29 |
# File 'lib/twb/codedfield.rb', line 27 def rawCode @rawCode end |
#techCode ⇒ Object (readonly)
Returns the value of attribute techCode
27 28 29 |
# File 'lib/twb/codedfield.rb', line 27 def techCode @techCode end |
Instance Method Details
#<=>(other) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/twb/codedfield.rb', line 77 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.techCode end |
#id ⇒ Object
69 70 71 |
# File 'lib/twb/codedfield.rb', line 69 def id @id ||= @id = "#{@dataSource}::#{@uiname}" end |
#parseField(str) ⇒ Object
initialize
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/twb/codedfield.rb', line 57 def parseField str # puts "parseField: #{str}" parts = str.split(':') case parts.length when 1 @name = parts[0] else @name = parts[-2] @function = parts[0] end end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/twb/codedfield.rb', line 73 def to_s "ds:#{dataSource}|n:#{name}|tc:#{techCode}" end |