Method: URI::Data#open

Defined in:
lib/data_uri/open_uri.rb

#openObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/data_uri/open_uri.rb', line 5

def open
  io = StringIO.new(data)
  OpenURI::Meta.init(io)
  io.meta_add_field('content-type', content_type)
  if block_given?
    begin
      yield io
    ensure
      io.close
    end
  else
    io
  end
end