Class: Coopy::SimpleMeta
- Inherits:
-
Object
- Object
- Coopy::SimpleMeta
- Defined in:
- lib/lib/coopy/simple_meta.rb
Instance Method Summary collapse
- #add_meta_data(column, property, val) ⇒ Object
- #alter_columns(columns) ⇒ Object
- #apply_flags(flags) ⇒ Object
- #as_table ⇒ Object
- #change_row(rc) ⇒ Object
- #clone_meta(table = nil) ⇒ Object
- #get_name ⇒ Object
- #get_row_stream ⇒ Object
-
#initialize(t, has_properties = true, may_be_nested = false) ⇒ SimpleMeta
constructor
A new instance of SimpleMeta.
- #is_nested ⇒ Object
- #is_sql ⇒ Object
- #store_row_changes(changes) ⇒ Object
- #use_for_column_changes ⇒ Object
- #use_for_row_changes ⇒ Object
Constructor Details
#initialize(t, has_properties = true, may_be_nested = false) ⇒ SimpleMeta
Returns a new instance of SimpleMeta.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lib/coopy/simple_meta.rb', line 7 def initialize(t,has_properties = true,may_be_nested = false) @t = t self.row_change self.col_change @has_properties = has_properties @may_be_nested = may_be_nested = nil @keys = nil @row_active = false @row_change_cache = nil end |
Instance Method Details
#add_meta_data(column, property, val) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/lib/coopy/simple_meta.rb', line 182 def (column,property,val) if == nil = {} @keys = {} end if !.include?(column) value = {} [column] = value end props = [column] begin value1 = val begin value2 = value1 props[property] = value2 end end @keys[property] = true end |
#alter_columns(columns) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/lib/coopy/simple_meta.rb', line 92 def alter_columns(columns) target = {} wfate = 0 if @has_properties target["@"] = wfate wfate+=1 end begin _g1 = 0 _g = columns.length while(_g1 < _g) i = _g1 _g1+=1 col = columns[i] target[col.prev_name] = wfate if col.prev_name != nil wfate+=1 if col.name != nil end end fate = Array.new begin _g11 = 0 _g2 = @t.get_width while(_g11 < _g2) i1 = _g11 _g11+=1 targeti = -1 name = @t.get_cell(i1,0) targeti = target[name] if target.include?(name) fate.push(targeti) end end @t.insert_or_delete_columns(fate,wfate) start = nil if @has_properties start = 1 else start = 0 end at = start begin _g12 = 0 _g3 = columns.length while(_g12 < _g3) i2 = _g12 _g12+=1 col1 = columns[i2] if col1.name != nil @t.set_cell(at,0,col1.name) if col1.name != col1.prev_name end at+=1 if col1.name != nil end end return true if !@has_properties self.col_change at = start begin _g13 = 0 _g4 = columns.length while(_g13 < _g4) i3 = _g13 _g13+=1 col2 = columns[i3] if col2.name != nil _g21 = 0 _g31 = col2.props while(_g21 < _g31.length) prop = _g31[_g21] _g21+=1 self.set_cell(col2.name,prop.name,prop.val) end end at+=1 if col2.name != nil end end true end |
#apply_flags(flags) ⇒ Object
291 292 293 |
# File 'lib/lib/coopy/simple_meta.rb', line 291 def apply_flags(flags) false end |
#as_table ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/lib/coopy/simple_meta.rb', line 202 def as_table return @t if @has_properties && == nil return nil if == nil w = @t.get_width props = Array.new _it = ::Rb::RubyIterator.new(@keys.keys) while(_it.has_next) do k = _it._next props.push(k) end props.sort!{|a,b| Reflect.compare(a,b)} mt = ::Coopy::SimpleTable.new(w + 1,props.length + 1) mt.set_cell(0,0,"@") begin _g = 0 while(_g < w) x = _g _g+=1 name = @t.get_cell(x,0) mt.set_cell(1 + x,0,name) next if !.include?(name) vals = [name] begin _g2 = 0 _g1 = props.length while(_g2 < _g1) i = _g2 _g2+=1 mt.set_cell(1 + x,i + 1,vals[props[i]]) if vals.include?(props[i]) end end end end begin _g11 = 0 _g3 = props.length while(_g11 < _g3) y = _g11 _g11+=1 mt.set_cell(0,y + 1,props[y]) end end mt end |
#change_row(rc) ⇒ Object
286 287 288 289 |
# File 'lib/lib/coopy/simple_meta.rb', line 286 def change_row(rc) @row_change_cache.push(rc) false end |
#clone_meta(table = nil) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/lib/coopy/simple_meta.rb', line 247 def (table = nil) result = ::Coopy::SimpleMeta.new(table) if != nil result.keys = {} _it = ::Rb::RubyIterator.new(@keys.keys) while(_it.has_next) do k = _it._next result.keys[k] = true end result. = {} _it2 = ::Rb::RubyIterator.new(.keys) while(_it2.has_next) do k1 = _it2._next next if !.include?(k1) vals = [k1] nvals = {} _it3 = ::Rb::RubyIterator.new(vals.keys) while(_it3.has_next) do p = _it3._next value = vals[p] begin value1 = value nvals[p] = value1 end end result.[k1] = nvals end end result end |
#get_name ⇒ Object
307 308 309 |
# File 'lib/lib/coopy/simple_meta.rb', line 307 def get_name nil end |
#get_row_stream ⇒ Object
295 296 297 |
# File 'lib/lib/coopy/simple_meta.rb', line 295 def get_row_stream ::Coopy::TableStream.new(@t) end |
#is_nested ⇒ Object
299 300 301 |
# File 'lib/lib/coopy/simple_meta.rb', line 299 def is_nested @may_be_nested end |
#is_sql ⇒ Object
303 304 305 |
# File 'lib/lib/coopy/simple_meta.rb', line 303 def is_sql false end |
#store_row_changes(changes) ⇒ Object
33 34 35 36 |
# File 'lib/lib/coopy/simple_meta.rb', line 33 def store_row_changes(changes) @row_change_cache = changes @row_active = true end |
#use_for_column_changes ⇒ Object
278 279 280 |
# File 'lib/lib/coopy/simple_meta.rb', line 278 def use_for_column_changes true end |
#use_for_row_changes ⇒ Object
282 283 284 |
# File 'lib/lib/coopy/simple_meta.rb', line 282 def use_for_row_changes @row_active end |