Class: Twb::MetadataField

Inherits:
TabClass show all
Includes:
Comparable
Defined in:
lib/twb/metadatafield.rb

Instance Attribute Summary collapse

Attributes inherited from TabClass

#ttlogfile, #ttlogfilename, #type, #uuid

Instance Method Summary collapse

Methods inherited from TabClass

#docFile, #emit, #setDocFileName

Constructor Details

#initialize(fieldNode) ⇒ MetadataField

Returns a new instance of MetadataField.


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/twb/metadatafield.rb', line 58

def initialize fieldNode
  @node              = fieldNode
  @twbClass          = @node.attribute('class').text
  @parentName        = load 'parent-name'
  @family            = load 'family'
  @table             = @family.nil? ? @parentName : @family
  @remoteName        = load 'remote-name' 
  @remoteAlias       = load 'remote-alias'
  @remoteType        = load 'remote-type'
  @caption           = load 'caption'   
  @localName         = load 'local-name'
  @name              = @localName
  @uiname            = @caption.nil? ? @localName : @caption
  @aggregation       = load 'aggregation'
  @containsNull      = load 'contains-null'
  @localType         = load 'local-type'
  @ordinal           = load 'ordinal'
  @precision         = load 'precision'
  @scale             = load 'scale'
  @width             = load 'width'
  @id                = "'%s::%s' " % [@table,@remoteName]   
end

Instance Attribute Details

#aggregationObject (readonly)

Returns the value of attribute aggregation


32
33
34
# File 'lib/twb/metadatafield.rb', line 32

def aggregation
  @aggregation
end

#captionObject (readonly)

Returns the value of attribute caption


29
30
31
# File 'lib/twb/metadatafield.rb', line 29

def caption
  @caption
end

#containsNullObject (readonly)

Returns the value of attribute containsNull


33
34
35
# File 'lib/twb/metadatafield.rb', line 33

def containsNull
  @containsNull
end

#familyObject (readonly)

Returns the value of attribute family


30
31
32
# File 'lib/twb/metadatafield.rb', line 30

def family
  @family
end

#localNameObject (readonly)

Returns the value of attribute localName


28
29
30
# File 'lib/twb/metadatafield.rb', line 28

def localName
  @localName
end

#localTypeObject (readonly)

Returns the value of attribute localType


30
31
32
# File 'lib/twb/metadatafield.rb', line 30

def localType
  @localType
end

#nameObject (readonly)

Returns the value of attribute name


28
29
30
# File 'lib/twb/metadatafield.rb', line 28

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node


24
25
26
# File 'lib/twb/metadatafield.rb', line 24

def node
  @node
end

#ordinalObject (readonly)

Returns the value of attribute ordinal


33
34
35
# File 'lib/twb/metadatafield.rb', line 33

def ordinal
  @ordinal
end

#parentNameObject (readonly)

parentName is the Db table


27
28
29
# File 'lib/twb/metadatafield.rb', line 27

def parentName
  @parentName
end

#precisionObject (readonly)

Returns the value of attribute precision


34
35
36
# File 'lib/twb/metadatafield.rb', line 34

def precision
  @precision
end

#propertiesObject (readonly)

Returns the value of attribute properties


24
25
26
# File 'lib/twb/metadatafield.rb', line 24

def properties
  @properties
end

#remoteAliasObject (readonly)

Returns the value of attribute remoteAlias


31
32
33
# File 'lib/twb/metadatafield.rb', line 31

def remoteAlias
  @remoteAlias
end

#remoteNameObject (readonly)

Returns the value of attribute remoteName


31
32
33
# File 'lib/twb/metadatafield.rb', line 31

def remoteName
  @remoteName
end

#remoteTypeObject (readonly)

Returns the value of attribute remoteType


32
33
34
# File 'lib/twb/metadatafield.rb', line 32

def remoteType
  @remoteType
end

#scaleObject (readonly)

Returns the value of attribute scale


34
35
36
# File 'lib/twb/metadatafield.rb', line 34

def scale
  @scale
end

#sourceObject

Returns the value of attribute source


26
27
28
# File 'lib/twb/metadatafield.rb', line 26

def source
  @source
end

#tableObject (readonly)

parentName is the Db table


27
28
29
# File 'lib/twb/metadatafield.rb', line 27

def table
  @table
end

#twbClassObject (readonly)

Returns the value of attribute twbClass


25
26
27
# File 'lib/twb/metadatafield.rb', line 25

def twbClass
  @twbClass
end

#uinameObject (readonly)

Returns the value of attribute uiname


29
30
31
# File 'lib/twb/metadatafield.rb', line 29

def uiname
  @uiname
end

#widthObject (readonly)

Returns the value of attribute width


34
35
36
# File 'lib/twb/metadatafield.rb', line 34

def width
  @width
end

Instance Method Details

#<=>(other) ⇒ Object


112
113
114
# File 'lib/twb/metadatafield.rb', line 112

def <=>(other)
  @id <=> other.id
end

#idObject


81
82
83
# File 'lib/twb/metadatafield.rb', line 81

def id
    @id ||= @id = @name.hash
end

#load(nodeName) ⇒ Object


102
103
104
105
106
# File 'lib/twb/metadatafield.rb', line 102

def load nodeName
  node = @node.at_xpath(nodeName)
  val = node.nil? ? nil : node.text.strip.gsub(/^\[|\]$/,'')
  return val
end

#loadPropertiesObject


89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/twb/metadatafield.rb', line 89

def loadProperties
  @properties = {}
  children = @node.xpath('child::node()')
  children.each do |child|
    @properties[child.name] = child.text unless 'attributes'.eql? child.name
  end
  @properties[:uiname] = @uiname
  @node.attributes.each do |name,attr|
    @properties[name] = attr.value
  end
  return @properties
end

#to_sObject


108
109
110
# File 'lib/twb/metadatafield.rb', line 108

def to_s
  @id
end