Class: Treemap21

Inherits:
Object
  • Object
show all
Defined in:
lib/treemap21.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, orientation: :landscape, debug: false) ⇒ Treemap21

Returns a new instance of Treemap21.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/treemap21.rb', line 13

def initialize(obj, orientation: :landscape, debug: false)

  @orientation, @debug = orientation, debug
      
  @a = case obj
  when Array
    a
  when String

    if obj.lstrip =~ /<?polyrex / then
      
      px = Polyrex.new obj                
      doc = Rexle.new(px.to_tree)
      scan_xml(doc.root)        
    
    elsif obj.lstrip =~ /</ then
      
      doc = Rexle.new(obj)
      scan_xml(doc.root)        
      
    else
      
      # most likely a raw polyrex document without the processing 
      # instruction or header
      
      head =  "<?polyrex schema='items[title, description]/item[title," +
          " pct, url]' delimiter=' # '?>\ntitle: Unititled\ndescription: " + 
          "Treemap record data"

      s = head + "\n\n" + obj.lstrip
      px = Polyrex.new s
      doc = Rexle.new(px.to_tree)
      scan_xml(doc.root)        
      
    end
    
  end

  @to_html = build_html()
  
end

Instance Attribute Details

#to_htmlObject (readonly)

Returns the value of attribute to_html.



11
12
13
# File 'lib/treemap21.rb', line 11

def to_html
  @to_html
end