るりまサーチ

最速Rubyリファレンスマニュアル検索!
2020件ヒット [1-100件を表示] (0.053秒)
トップページ > クエリ:>[x] > クラス:IO[x]

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. float >
  4. module >
  5. complex >

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

IO#set_encoding_by_bom -> Encoding | nil (113.0)

BOM から IO のエンコーディングを設定します。

...BOM から IO のエンコーディングを設定します。

自身が BOM から始まる場合、BOM を読み進めて外部エンコーディングをセットし、セットしたエンコーディングを返します。
BOM が見つからなかった場合は nil を返します。

...
...t", "rb") do |io|
p io.set_encoding_by_bom #=> #<Encoding:UTF-8>
str = io.read
p str #=> "abc"
p str.encoding #=> #<Encoding:UTF-8>
end

File.write("nobom.txt", "abc")
File.open("nobom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> nil
end
//}...

IO#binmode -> self (107.0)

ストリームをバイナリモードにします。MSDOS などバイナリモードの存在 する OS でのみ有効です。そうでない場合このメソッドは何もしません。

...ンしかありません。

@raise Errno::EXXX モードの変更に失敗した場合に発生します。

//emlist[例][ruby]{
IO
.open(IO.sysopen("testfile", "w+")) do |io|
io
.binmode? # => false
io
.binmode # => #<IO:fd 8>
io
.binmode? # => true
end
//}

@see c:IO#io_binmode, IO#binmode?...

IO#each_char -> Enumerator (107.0)

self に含まれる文字を一文字ずつブロックに渡して評価します。

...ません。

ブロックを省略した場合は各文字について繰り返す Enumerator を返します。

@raise IOError self が読み込み用にオープンされていない場合に発生します。

f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>...

IO#each_char {|c| ... } -> self (107.0)

self に含まれる文字を一文字ずつブロックに渡して評価します。

...ません。

ブロックを省略した場合は各文字について繰り返す Enumerator を返します。

@raise IOError self が読み込み用にオープンされていない場合に発生します。

f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>...

IO#external_encoding -> Encoding | nil (107.0)

IO の外部エンコーディングを返します。 外部エンコーディングが指定されていない場合は nil を返します。 ただし読み込み専用モードの場合は Encoding.default_external になります。

...
IO
の外部エンコーディングを返します。
外部エンコーディングが指定されていない場合は nil を返します。
ただし読み込み専用モードの場合は Encoding.default_external になります。

//emlist[例][ruby]{
IO
.write("testfile", "abcde")
File.ope...
...n("testfile") { |f| p f.external_encoding } # => #<Encoding:UTF-8>
//}...

絞り込み条件を変える

IO#internal_encoding -> Encoding | nil (107.0)

IO の内部エンコーディングを返します。 内部エンコーディングが指定されていない場合は nil を返します。

...
IO
の内部エンコーディングを返します。
内部エンコーディングが指定されていない場合は nil を返します。

//emlist[例][ruby]{
IO
.write("testfile", "abcde")
File.open("testfile") do |f|
p f.internal_encoding # => nil
f.set_encoding("ASCII-8BIT", "EUC-JP"...
...)
p f.internal_encoding # => #<Encoding:EUC-JP>
end
//}...

IO#reopen(path) -> self (107.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...ぎます。
IO
#pos, IO#lineno などはリセットされます。

@param path パスを表す文字列を指定します。

@param mode パスを開く際のモードを文字列で指定します。

@raise Errno::EXXX 失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("test...
....new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") # => #<File:testfile>
f2.readlines # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//...

IO#reopen(path, mode) -> self (107.0)

path で指定されたファイルにストリームを繋ぎ換えます。

...ぎます。
IO
#pos, IO#lineno などはリセットされます。

@param path パスを表す文字列を指定します。

@param mode パスを開く際のモードを文字列で指定します。

@raise Errno::EXXX 失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("test...
....new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") # => #<File:testfile>
f2.readlines # => ["This is line one\n", "This is line two\n", "This is line three\n"]
f2.close
//...

IO#ungetbyte(c) -> nil (107.0)

指定したバイト列を書き戻します。

...し(IO#sysread など)
には影響しません。

@param c バイト列(文字列)、もしくは0から255までの整数

例:

f = File.new("testfile") #=> #<File:testfile>
b = f.getbyte #=> 0x38
f.ungetbyte(b) #=> nil
f.getbyte #=> 0x38...
<< 1 2 3 ... > >>