るりまサーチ

最速Rubyリファレンスマニュアル検索!
240件ヒット [1-100件を表示] (0.076秒)

別のキーワード

  1. string []=
  2. string slice
  3. string slice!
  4. string []
  5. string gsub

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 > >>

IO.write(path, string, **opts) -> Integer (18245.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。

offset を指定するとその位置までシー...
...param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.write("testfile", text) # => 66
IO.write("te...
...stfile", "0123456789", 20) #=> 10
IO.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO.write("testfile", "0123456789") #=> 10
IO.read("testfile") # => "0123456789"
//}

@see IO.binwrite...

IO.write(path, string, offset=nil, **opts) -> Integer (18245.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

Kernel.#open と同様 path の先頭が "|" ならば、"|" に続くコマンドを実行し、コマンドの出力を標準出力に書き込みます。

offset を指定するとその位置までシー...
...param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO.write("testfile", text) # => 66
IO.write("te...
...stfile", "0123456789", 20) #=> 10
IO.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO.write("testfile", "0123456789") #=> 10
IO.read("testfile") # => "0123456789"
//}

@see IO.binwrite...

IO.binwrite(path, string, offset=nil) -> Integer (6242.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...path で指定されるファイルを開き、string を書き込み、
閉じます。

ファイルを開くときの mode が "rb:ASCII-8BIT" で、バイナリモードが有効
である点以外は IO.write と同じです。

Kernel.#open と同様 path の先頭が "|" ならば、"|" に...
...す。

offset を指定しないと、書き込みの末尾でファイルを
切り捨てます。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置

//emlist[例][ruby]{
# 8x8の真っ白なPNG画像データ。
png = 'iVBORw0KGgoAAAA...
...49 48 44 52

# binwriteを使用した場合: どの環境でも正しく保存できる。
IO.binwrite('white.binmode.png', png)
puts IO.binread('white.binmode.png', 16).unpack('C*').map {|c| '%02x' % c }.join(' ')
# => 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52

# binwriteを使用しなか...

OpenSSL::PKCS7.write_smime(p7sig, data=nil, flags = 0) -> String (6209.0)

PKCS7 オブジェクトから S/MIME 形式の文字列を返します。

....read('cert.pem')),
OpenSSL::PKey::RSA.new(File.read('privkey.pem')),
data)
smime = PKCS7.write_smime(p7)

@param p7sig PKCS#7 オブジェクト
@param data 署名されたデータ文字列
@param flags フラグ(整数値)
@raise OpenSSL::...

StringIO.new(string = &#39;&#39;, mode = &#39;r+&#39;) -> StringIO (3240.0)

StringIO オブジェクトを生成して返します。

...
String
IO オブジェクトを生成して返します。

与えられた string がフリーズされている場合には、mode はデフォルトでは読み取りのみに設定されます。
ブロックを与えた場合は生成した StringIO オブジェクトを引数としてブロッ...
...価してその結果を返します。

@param string 生成される StringIO のデータを文字列で指定します。
この文字列はバッファとして使われます。StringIO#write などによって、
string
自身も書き換えられます。

@param...
...字列か整数で指定します。

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

//emlist[例][ruby]{
require 'stringio'

s = "foo"
io = StringIO.new(s)
p io.getc # => 102
p io.pos # => 1
p...

絞り込み条件を変える

StringIO.open(string = &#39;&#39;, mode = &#39;r+&#39;) -> StringIO (3240.0)

StringIO オブジェクトを生成して返します。

...
String
IO オブジェクトを生成して返します。

与えられた string がフリーズされている場合には、mode はデフォルトでは読み取りのみに設定されます。
ブロックを与えた場合は生成した StringIO オブジェクトを引数としてブロッ...
...価してその結果を返します。

@param string 生成される StringIO のデータを文字列で指定します。
この文字列はバッファとして使われます。StringIO#write などによって、
string
自身も書き換えられます。

@param...
...字列か整数で指定します。

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

//emlist[例][ruby]{
require 'stringio'

s = "foo"
io = StringIO.new(s)
p io.getc # => 102
p io.pos # => 1
p...

StringIO.open(string = &#39;&#39;, mode = &#39;r+&#39;) {|io| ... } -> object (3140.0)

StringIO オブジェクトを生成して返します。

...
String
IO オブジェクトを生成して返します。

与えられた string がフリーズされている場合には、mode はデフォルトでは読み取りのみに設定されます。
ブロックを与えた場合は生成した StringIO オブジェクトを引数としてブロッ...
...価してその結果を返します。

@param string 生成される StringIO のデータを文字列で指定します。
この文字列はバッファとして使われます。StringIO#write などによって、
string
自身も書き換えられます。

@param...
...字列か整数で指定します。

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

//emlist[例][ruby]{
require 'stringio'

s = "foo"
io = StringIO.new(s)
p io.getc # => 102
p io.pos # => 1
p...

IO.readlines(path, limit, chomp: false, opts={}) -> [String] (116.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...t[例][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO.write("testfile", "lin...

IO.readlines(path, rs = $/, chomp: false, opts={}) -> [String] (116.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...t[例][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO.write("testfile", "lin...
<< 1 2 3 > >>