Class: TextSerializer
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
366
367
368
|
# File 'lib/rfeedparser.rb', line 366
def write(stream=$stdout)
writer(stream, @results, '')
end
|
#writer(stream, node, prefix) ⇒ Object
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
# File 'lib/rfeedparser.rb', line 370
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
|