ox
ox copied to clipboard
`StringIO` in `Ox::Builder`
Hello! It possible use StringIO
in Ox::Builder
?
require 'ox'
io = StringIO.new
b = Ox::Builder.io(io, indent: 2) # Here I get an exception: `io': expected an IO that has a fileno. (IOError)
10.times do
b.element('node') do
b.text('value')
end
end
b.close
io.to_s
Currently only files are supported. I'll looking into supporting anything that can be written to. Sorry for being slow to respond.
It would be too much of a change to support StringIO with little gain. Did you know you can create a new Builder without and io and it will build a string? Line 1472 of the test.rb file is an example of that.