--- !ruby/object:RDoc::RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: Returns a new <tt>IO</tt> object (a stream) for the given <tt>IO</tt> object or integer file descriptor and mode string. See also <tt>IO#fileno</tt> and <tt>IO.for_fd</tt>.
- !ruby/struct:RDoc::Markup::Flow::H 
  :level: 3
  :text: Parameters
- !ruby/object:RDoc::Markup::Flow::LIST 
  contents: 
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "fd:"
    :body: numeric file descriptor
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "mode:"
    :body: file mode. a string or an integer
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "opt:"
    :body: hash for specifiying mode by name.
  type: :NOTE
- !ruby/struct:RDoc::Markup::Flow::H 
  :level: 4
  :text: Mode
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: When <tt>mode</tt> is an integer it must be combination of the modes defined in <tt>File::Constants</tt>.
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: "When <tt>mode</tt> is a string it must be in one of the following forms:"
- !ruby/object:RDoc::Markup::Flow::LIST 
  contents: 
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "-"
    :body: "&quot;fmode&quot;,"
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "-"
    :body: "&quot;fmode:extern&quot;,"
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: "-"
    :body: "&quot;fmode:extern:intern&quot;."
  type: :BULLET
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: <tt>extern</tt> is the external encoding name for the IO. <tt>intern</tt> is the internal encoding. <tt>fmode</tt> must be combination of the directives. See the description of class <tt>IO</tt> for a description of the directives.
- !ruby/struct:RDoc::Markup::Flow::H 
  :level: 4
  :text: Options
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: <tt>opt</tt> can have the following keys
- !ruby/object:RDoc::Markup::Flow::LIST 
  contents: 
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":mode :"
    :body: same as <tt>mode</tt> parameter
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":external_encoding :"
    :body: external encoding for the IO. &quot;-&quot; is a synonym for the default external encoding.
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":internal_encoding :"
    :body: internal encoding for the IO. &quot;-&quot; is a synonym for the default internal encoding. If the value is nil no conversion occurs.
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":encoding :"
    :body: specifies external and internal encodings as &quot;extern:intern&quot;.
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":textmode :"
    :body: If the value is truth value, same as &quot;b&quot; in argument <tt>mode</tt>.
  - !ruby/struct:RDoc::Markup::Flow::LI 
    :label: ":binmode :"
    :body: If the value is truth value, same as &quot;t&quot; in argument <tt>mode</tt>.
  type: :NOTE
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: Also <tt>opt</tt> can have same keys in <tt>String#encode</tt> for controlling conversion between the external encoding and the internal encoding.
- !ruby/struct:RDoc::Markup::Flow::H 
  :level: 3
  :text: Example1
- !ruby/struct:RDoc::Markup::Flow::VERB 
  :body: "   puts IO.new($stdout).fileno # =&gt; 1\n\n   a = IO.new(2,&quot;w&quot;)      # '2' is standard error\n   $stderr.puts &quot;Hello&quot;\n   a.puts &quot;World&quot;\n"
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: <em>produces:</em>
- !ruby/struct:RDoc::Markup::Flow::VERB 
  :body: "   Hello\n   World\n"
- !ruby/struct:RDoc::Markup::Flow::H 
  :level: 3
  :text: Example2
- !ruby/struct:RDoc::Markup::Flow::VERB 
  :body: "   io = IO.new(2, mode: 'w:UTF-16LE', cr_newline: true)\n   io.puts &quot;Hello, World!&quot;\n\n   io = IO.new(2, mode: 'w', cr_newline: true, external_encoding: Encoding::UTF_16LE)\n   io.puts &quot;Hello, World!&quot;\n"
- !ruby/struct:RDoc::Markup::Flow::P 
  :body: both of aboves print &quot;Hello, World!&quot; in UTF-16LE to standard error output with converting EOL generated by <tt>puts</tt> to CR.
full_name: IO::new
is_singleton: true
name: new
params: |
  IO.new(fd [, mode] [, opt])   => io

visibility: public
