Class: Twb::QuickFilter

Inherits:
Object
  • Object
show all
Includes:
TabTool
Defined in:
lib/twb/quickfilter.rb

Instance Attribute Summary collapse

Attributes included from TabTool

#alerts, #docDir, #docfiles, #funcdoc, #id, #licensed, #logfilename, #logger, #loglevel, #metrics, #properties, #ttdocdir, #uuid

Instance Method Summary collapse

Methods included from TabTool

#addDocFile, #alert, #closeDocFiles, #config, #docFile, #docFileMaxNameLen, #docfilesdoc, #docfilesdocto_s, #emit, #emitCSV, #finis, #hasConfig, #init, #initCSV, #initDocDir, #initLogger, #license=, #licensed?, #loadConfig

Constructor Details

#initialize(node, twb) ⇒ QuickFilter



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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/twb/quickfilter.rb', line 31

def initialize(node,twb)
  init
  emit "\nFILTER:\n#{node}\n====="
  @node         = node
  filterClass   = @node['class']
  @type         = filterClass.gsub('-',' ').capitalize
  @kind         = @node['kind']
  fieldCode     = node['column']
  codedField    = Twb::CodedField.new(fieldCode) 
  fieldTech     = codedField.name
  inexclusions  = fieldTech =~ /^(Ex|In)clusions/
  @measureNames = ':Measure Names' == fieldTech
  srcTech       = codedField.dataSource
  @dataSource   = twb.datasource(srcTech)
  @dsAliases    = @dataSource.aliases
  field         = @measureNames || inexclusions ? fieldTech : @dataSource.field(fieldTech)
  uiname        = @dataSource.fieldUIName(fieldTech)
  @uiname       = @measureNames || inexclusions ? fieldTech : uiname.nil? ? fieldTech : uiname
  @field        = @uiname
  @includeNull  = if @node['include-null'].nil? 
                     true
                  elsif 'false' == @node['include-null']
                     false
                  else
                    true
                  end
  @values       = []
  enode      = @node.at_xpath('.//*[@user:ui-enumeration]')
  @inexclude = if enode.nil?
                  'Include'
               else case enode['user:ui-enumeration']
                      when 'inclusive' then 'Include'
                      when 'exclusive' then 'Exclude'
                      when  nil   then 'Include'
                      when 'all'  then 'Include'
                      else             'undefined'
                    end 
               end
  @inexMode  = enode.nil? ? 'Default' : 'Specified'
  emit "\n::  FIELD  :: #{field} == #{@uiname}   --  #{fieldTech}  --  #{codedField.rawCode}"
  emit "       filter class: #{filterClass}"
  emit "         field code: #{fieldCode}"
  emit "        coded field: #{codedField}"
  emit "         field tech: #{fieldTech}"
  emit "         field name: nil? #{@uiname.nil?}   #{@uiname}  "
  emit "           src tech: #{srcTech}"
  emit "       @measureNames: #{@measureNames}"
  emit "                 ds: #{@dataSource.uiname}"
  emit "              field: #{@uiname}"
  emit "         @inexclude: #{@inexclude}"
  emit " "
  aaa = case filterClass
    when 'relative-date' then resolveRelativeDate
    when 'quantitative'  then resolveQuantitative
    when 'categorical'   then resolveCategoricalValues
  end
end

Instance Attribute Details

#dataSourceObject (readonly)

Returns the value of attribute dataSource.



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

def dataSource
  @dataSource
end

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#includeNullObject (readonly)

Returns the value of attribute includeNull.



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

def includeNull
  @includeNull
end

#inexcludeObject (readonly)

Returns the value of attribute inexclude.



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

def inexclude
  @inexclude
end

#inexModeObject (readonly)

Returns the value of attribute inexMode.



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

def inexMode
  @inexMode
end

#kindObject (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



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

def node
  @node
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#uinameObject (readonly)

Returns the value of attribute uiname.



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

def uiname
  @uiname
end

#valuesObject (readonly)

Returns the value of attribute values.



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

def values
  @values
end

Instance Method Details

#context?Boolean

def initialize



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

def context?
  @iscontext ||= @node['context']
end

#to_sObject



93
94
95
# File 'lib/twb/quickfilter.rb', line 93

def to_s
    "%s => %s" % [uiname, values]
end