Class: Coopy::Index
- Inherits:
-
Object
- Object
- Coopy::Index
- Defined in:
- lib/lib/coopy/index.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#items ⇒ Object
Returns the value of attribute items.
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#top_freq ⇒ Object
Returns the value of attribute top_freq.
Instance Method Summary collapse
- #add_column(i) ⇒ Object
- #get_table ⇒ Object
- #index_table(t, hdr) ⇒ Object
-
#initialize(flags) ⇒ Index
constructor
A new instance of Index.
- #to_key(t, i) ⇒ Object
- #to_key_by_content(row) ⇒ Object
Constructor Details
#initialize(flags) ⇒ Index
Returns a new instance of Index.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/lib/coopy/index.rb', line 7 def initialize(flags) @items = {} @cols = Array.new @keys = Array.new @top_freq = 0 @height = 0 @hdr = 0 @ignore_whitespace = false @ignore_whitespace = flags.ignore_whitespace if flags != nil end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
21 22 23 |
# File 'lib/lib/coopy/index.rb', line 21 def height @height end |
#items ⇒ Object
Returns the value of attribute items.
18 19 20 |
# File 'lib/lib/coopy/index.rb', line 18 def items @items end |
#keys ⇒ Object
Returns the value of attribute keys.
19 20 21 |
# File 'lib/lib/coopy/index.rb', line 19 def keys @keys end |
#top_freq ⇒ Object
Returns the value of attribute top_freq.
20 21 22 |
# File 'lib/lib/coopy/index.rb', line 20 def top_freq @top_freq end |
Instance Method Details
#add_column(i) ⇒ Object
33 34 35 |
# File 'lib/lib/coopy/index.rb', line 33 def add_column(i) @cols.push(i) end |
#get_table ⇒ Object
117 118 119 |
# File 'lib/lib/coopy/index.rb', line 117 def get_table @indexed_table end |
#index_table(t, hdr) ⇒ Object
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 |
# File 'lib/lib/coopy/index.rb', line 37 def index_table(t,hdr) @indexed_table = t @hdr = hdr @keys[t.get_height - 1] = nil if @keys.length != t.get_height && t.get_height > 0 begin _g1 = 0 _g = t.get_height while(_g1 < _g) i = _g1 _g1+=1 key = @keys[i] if key == nil key = self.to_key(t,i) @keys[i] = key end item = @items[key] if item == nil item = ::Coopy::IndexItem.new @items[key] = item end ct = nil begin item.lst = Array.new if item.lst == nil item.lst.push(i) ct = item.lst.length end @top_freq = ct if ct > @top_freq end end @height = t.get_height end |
#to_key(t, i) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/lib/coopy/index.rb', line 69 def to_key(t,i) wide = nil if i < @hdr wide = "_" else wide = "" end @v = t.get_cell_view if @v == nil begin _g1 = 0 _g = @cols.length while(_g1 < _g) k = _g1 _g1+=1 d = t.get_cell(@cols[k],i) txt = @v.to_s(d) txt = txt.strip if @ignore_whitespace wide += " // " if k > 0 next if txt == nil || txt == "" || txt == "null" || txt == "undefined" wide += txt end end wide end |
#to_key_by_content(row) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/lib/coopy/index.rb', line 94 def to_key_by_content(row) wide = nil if row.is_preamble wide = "_" else wide = "" end begin _g1 = 0 _g = @cols.length while(_g1 < _g) k = _g1 _g1+=1 txt = row.get_row_string(@cols[k]) txt = txt.strip if @ignore_whitespace wide += " // " if k > 0 next if txt == nil || txt == "" || txt == "null" || txt == "undefined" wide += txt end end wide end |