class Twb::MetadataField

Attributes

aggregation[R]
caption[R]
containsNull[R]
family[R]
localName[R]
localType[R]
name[R]
node[R]
ordinal[R]
parentName[R]
precision[R]
properties[R]
remoteAlias[R]
remoteName[R]
remoteType[R]
scale[R]
source[RW]
table[R]
twbClass[R]
uiname[R]
width[R]

Public Class Methods

new(fieldNode) click to toggle source

Child nodes of <metadata-record nodes <aggregation <approx-count <attributes <caption <collation <contains-null <family <layered <local-name <local-type <ordinal <parent-name <precision <remote-alias <remote-name <remote-type <scale <statistics <width

# 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

Public Instance Methods

<=>(other) click to toggle source
# File lib/twb/metadatafield.rb, line 112
def <=>(other)
  @id <=> other.id
end
id() click to toggle source
# File lib/twb/metadatafield.rb, line 81
def id
    @id ||= @id = @name.hash
end
load(nodeName) click to toggle source
# 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
loadProperties() click to toggle source
# 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_s() click to toggle source
# File lib/twb/metadatafield.rb, line 108
def to_s
  @id
end