class Twb::Parameter

Attributes

caption[R]
currentValue[R]
dataType[R]
dataTypeCustom[R]
domainType[R]
format[R]
name[R]
node[R]
role[R]
type[R]
uiname[R]
values[R]

Public Class Methods

new(paramNode) click to toggle source
# File lib/twb/parameter.rb, line 31
def initialize(paramNode)
    @node       = paramNode
    # --
    @name           = @node['name'].gsub(/^\[|\]$/,'')
    @caption        = @node['caption']
    @uiname         = caption.nil? ? nameTech : caption
    @dataType       = @node['datatype']
    @format         = @node['default-format'].nil?      ? '<<default>>' : @node['default-format']
    @dataTypeCustom = @node['datatype-customized'].nil? ? false : true
    @domainType     = @node['param-domain-type']
    @role           = @node['role']
    @type           = @node['type']
    @currentValue   = paramNode.at_xpath('./calculation[@class="tableau"]')['formula'].gsub(/^[#"]|[#"]$/,'')
    @values         = []
    processNode
end

Public Instance Methods

to_s() click to toggle source
# File lib/twb/parameter.rb, line 48
def to_s
    "%s => %s" % [uiname, values]
end

Private Instance Methods

processAll() click to toggle source
# File lib/twb/parameter.rb, line 110
def processAll
  unless @hasMembers || @hasRange
    @values << {:value => '<<All>>'}
  end
end
processMembers() click to toggle source
# File lib/twb/parameter.rb, line 60
def processMembers
  #-- for when there are members, i.e. Lists
  # <column caption='Date - List' datatype='date' datatype-customized='true' name='[Date - All 9/5/2018 Std Short Date (copy)]' param-domain-type='list' role='measure' type='quantitative' value='#2002-01-02#'>
  #   <calculation class='tableau' formula='#2002-01-02#' />
  #   <members>
  #     <member value='#2002-01-02#' />
  #     <member value='#2006-12-05#' />
  #     <member value='#1999-11-01#' />
  #   </members>
  members    = @node.xpath('.//member')
  @hasMembers = !members.empty? 
  emit "# members: #{members.length}"
  members.each do |m|
    mvalue = m['value'].gsub(/^[#"]|[#"]$/,'')
    malias = m['alias']
    mvalui = malias.nil? ? mvalue : malias
    @values << {:valueTech => mvalue, :alias => malias, :value => mvalui}

  end
end
processNode() click to toggle source
# File lib/twb/parameter.rb, line 54
def processNode
    processMembers
    processRange
    processAll
end
processRange() click to toggle source
# File lib/twb/parameter.rb, line 81
def processRange
  # <column caption='Date - Range CV 3/3/2003 :  ...12/5/2006' datatype='date' datatype-customized='true' name='[Date - Range CV 8/29/2001 3/23/2000...12/5/2006 (copy)]' param-domain-type='range' role='measure' type='quantitative' value='#2003-03-03#'>
  #   <calculation class='tableau' formula='#2003-03-03#' />
  #   <range max='#2006-12-05#' />
  #--
  # <column caption='Integer List Range -73...2,109 SS1' datatype='integer' datatype-customized='true' name='[Integer List Primes (copy)]' param-domain-type='range' role='measure' type='quantitative' value='1'>
  #   <calculation class='tableau' formula='1' />
  #   <range max='2109' min='1' />
  # </column>
  #--
  # <column caption='Date - Range CV 8/29/2001 3/23/2000...' datatype='date' datatype-customized='true' name='[Date - Range CV 8/29/2001 3/23/2000...12/5/2006 (copy 2)]' param-domain-type='range' role='measure' type='quantitative' value='#2001-09-29#'>
  #   <calculation class='tableau' formula='#2001-09-29#' />
  #   <range min='#2000-03-23#' />
  # </column>
  #--
  # <column caption='Integer List Range -73...2,109 SS3' datatype='integer' datatype-customized='true' name='[Integer List Range -73...2,109 SS1 (copy)]' param-domain-type='range' role='measure' type='quantitative' value='1'>
  #   <calculation class='tableau' formula='1' />
  #   <range granularity='3' max='2109' min='1' />
  # </column>
  if 'range' == domainType
    @hasRange = true
    rangeNode = @node.at_xpath('./range')
    min = rangeNode['min'].nil? ? nil : rangeNode['min'].gsub(/^[#"]|[#"]$/,'')
    max = rangeNode['max'].nil? ? nil : rangeNode['max'].gsub(/^[#"]|[#"]$/,'')
    range = "#{min}...#{max}"
    @values << {:value => range}
  end
end