Class: TextSerializer

Inherits:
Serializer show all
Defined in:
lib/rfeedparser.rb

Instance Method Summary collapse

Methods inherited from Serializer

#initialize

Constructor Details

This class inherits a constructor from Serializer

Instance Method Details

#write(stream = $stdout) ⇒ Object



429
430
431
# File 'lib/rfeedparser.rb', line 429

def write(stream=$stdout)
  writer(stream, @results, '')
end

#writer(stream, node, prefix) ⇒ Object



433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/rfeedparser.rb', line 433

def writer(stream, node, prefix)
  return if (node.nil? or node.empty?)
  if node.methods.include?'keys'
    node.keys.sort.each do |key|
      next if ['description','link'].include? key
      next if node.has_key? k+'_detail'
      next if node.has_key? k+'_parsed'
      writer(stream,node[k], prefix+k+'.')
    end
  elsif node.class == Array
    node.each_with_index do |thing, index|
      writer(stream, thing, prefix[0..-2] + '[' + index.to_s + '].')
    end
  else
    begin
      s = u(node.to_s)
      stream << prefix[0..-2]
      stream << '='
      stream << s
      stream << "\n"
    rescue
    end
  end
end