Class: Twb::MetadataField

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fieldNode) ⇒ MetadataField

Returns a new instance of MetadataField.



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

def initialize fieldNode
  @class             = fieldNode.attribute('class').text
  @node              = fieldNode
  @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              = @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]   
  # return self
end

Instance Attribute Details

#aggregationObject (readonly)

Returns the value of attribute aggregation.



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

def aggregation
  @aggregation
end

#captionObject (readonly)

Returns the value of attribute caption.



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

def caption
  @caption
end

#classObject (readonly)

Returns the value of attribute class.



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

def class
  @class
end

#containsNullObject (readonly)

Returns the value of attribute containsNull.



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

def containsNull
  @containsNull
end

#familyObject (readonly)

Returns the value of attribute family.



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

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.



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

def localType
  @localType
end

#nameObject (readonly)

Returns the value of attribute name.



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

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.



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

def ordinal
  @ordinal
end

#parentNameObject (readonly)

parentName is the Db table



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

def parentName
  @parentName
end

#precisionObject (readonly)

Returns the value of attribute precision.



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

def precision
  @precision
end

#remoteAliasObject (readonly)

Returns the value of attribute remoteAlias.



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

def remoteAlias
  @remoteAlias
end

#remoteNameObject (readonly)

Returns the value of attribute remoteName.



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

def remoteName
  @remoteName
end

#remoteTypeObject (readonly)

Returns the value of attribute remoteType.



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

def remoteType
  @remoteType
end

#scaleObject (readonly)

Returns the value of attribute scale.



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

def scale
  @scale
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#tableObject (readonly)

parentName is the Db table



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

def table
  @table
end

#widthObject (readonly)

Returns the value of attribute width.



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

def width
  @width
end

Instance Method Details

#<=>(other) ⇒ Object



89
90
91
# File 'lib/twb/metadatafield.rb', line 89

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

#load(nodeName) ⇒ Object



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

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

#to_sObject



85
86
87
# File 'lib/twb/metadatafield.rb', line 85

def to_s
  @id
end