Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIO in Ox::Builder #293

Open
Yegorov opened this issue Jun 13, 2022 · 2 comments
Open

StringIO in Ox::Builder #293

Yegorov opened this issue Jun 13, 2022 · 2 comments

Comments

@Yegorov
Copy link

Yegorov commented Jun 13, 2022

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
@ohler55
Copy link
Owner

ohler55 commented Jun 22, 2022

Currently only files are supported. I'll looking into supporting anything that can be written to. Sorry for being slow to respond.

@ohler55
Copy link
Owner

ohler55 commented Jun 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants