るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. require execute

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

StringIO (14.0)

文字列に IO と同じインタフェースを持たせるためのクラスです。

...ラスです。

//emlist[例][ruby]{
require
"stringio"
sio = StringIO.new("hoge", 'r+')
p sio.read #=> "hoge"
sio.rewind
p sio.read(1) #=> "h"
sio.write("OGE")
sio.rewind
p sio.read #=> "hOGE"
//}

=== 例外
StringIO
オブジェクトは大抵の場...
...合 IO オブジェクトと同じ例外を発生させます。
例えば次の例では write は IOError を発生させます。

//emlist[例][ruby]{
require
"stringio"
sio = StringIO.new("hoge")
sio.close
sio.write("a")
# => in `write': not opened for writing (IOError)
//}...

StringIO#reopen(sio) -> StringIO (9.0)

自身が表す文字列が指定された StringIO と同じものになります。

...自身が表す文字列が指定された StringIO と同じものになります。

@param sio 自身が表したい StringIO を指定します。

//emlist[例][ruby]{
require
'stringio'
sio = StringIO.new("hoge", 'r+')
sio2 = StringIO.new("foo", 'r+')
sio.reopen(sio2)
p sio.read...

StringIO#reopen(str, mode = &#39;r+&#39;) -> StringIO (9.0)

自身が表す文字列が指定された文字列 str になります。

...ックを与えた場合は生成した StringIO オブジェクトを引数としてブロックを評価します。

@param str 自身が表したい文字列を指定します。
この文字列はバッファとして使われます。StringIO#write などによって、
s...
...を指定します。

@raise Errno::EACCES str がフリーズされていて、mode が書き込み可能に設定されている場合に発生します。

//emlist[例][ruby]{
require
'stringio'
sio = StringIO.new("hoge", 'r+')
sio.reopen('foo')
p sio.read #=> "foo"
//}...

StringIO#bytes -> Enumerator (8.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

StringIO#bytes {|ch| ... } -> self (8.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

絞り込み条件を変える

StringIO#closed? -> bool (8.0)

自身が既に close されていた場合に true を返します。そうでない場合は、false を返します。

...身が既に close されていた場合に true を返します。そうでない場合は、false を返します。

//emlist[例][ruby]{
require
"stringio"
sio = StringIO.open("hoge")
p sio.closed? # => false
sio.close_read
p sio.closed? # => false
sio.close_write
p sio.closed? # => true
//}...

StringIO#each(rs = $/) -> Enumerator (8.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

StringIO#each(rs = $/) {|line| ... } -> self (8.0)

自身から 1 行ずつ読み込み、それを引数として与えられたブロックを実行します。

...連続する改行を行の区切りとみなします(パラグラフモード)。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge\nfoo\n")
a.each{|l| p l }
#=> "hoge\n"
# "foo\n"
//}

@see $/
@see IO#each_line...

StringIO#each_byte -> Enumerator (8.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

StringIO#each_byte {|ch| ... } -> self (8.0)

自身から 1 バイトずつ読み込み、整数 ch に変換し、それを引数として与えられたブロックを実行します。

...変換し、それを引数として与えられたブロックを実行します。

@raise IOError 自身が読み取り不可なら発生します。

//emlist[例][ruby]{
require
"stringio"
a = StringIO.new("hoge")
a.each_byte{|ch| p ch }
#=> 104
# 111
# 103
# 101
//}

@see IO#each_byte...

絞り込み条件を変える

<< 1 2 3 ... > >>