Class: Goat::DOMTools::DOMAttrs
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Hash
Class Method Details
.from_hash(hash, id = nil) ⇒ Object
355 356 357 358 359 360 |
# File 'lib/goat/dom.rb', line 355 def self.from_hash(hash, id=nil) d = self[hash] d.id = id d.clean d end |
Instance Method Details
#clean ⇒ Object
368 369 370 371 372 373 374 375 |
# File 'lib/goat/dom.rb', line 368 def clean self.each do |k, v| if v.kind_of?(String) && v.start_with?('dom_') && (!@id || v !~ /#{@id}/) deleted[k] = v self.delete(k) end end end |
#deleted ⇒ Object
362 363 364 |
# File 'lib/goat/dom.rb', line 362 def deleted @deleted ||= {} end |
#id=(id) ⇒ Object
366 |
# File 'lib/goat/dom.rb', line 366 def id=(id); @id = id; end |
#inspect ⇒ Object
382 383 384 385 386 387 388 389 390 |
# File 'lib/goat/dom.rb', line 382 def inspect start = super[0..-2] o = [] deleted.each do |k, v| o << "#{k.inspect}=>**#{v.inspect}**" end start + (o.empty? ? '' : ', ' + o.join(', ')) + '}' end |
#reconstitute ⇒ Object
377 378 379 380 |
# File 'lib/goat/dom.rb', line 377 def reconstitute (deleted.keys - self.keys).each{|k| self[k] = deleted[k]} self end |