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
357
358
359
|
# File 'lib/rfeedparser.rb', line 357
def write(stream=$stdout)
writer(stream, @results, '')
end
|
#writer(stream, node, prefix) ⇒ Object
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
# File 'lib/rfeedparser.rb', line 361
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
|