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



443
444
445
# File 'lib/rfeedparser.rb', line 443

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

#writer(stream, node, prefix) ⇒ Object



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/rfeedparser.rb', line 447

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