るりまサーチ

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

別のキーワード

  1. stringio getc
  2. _builtin getc
  3. io getc
  4. zlib getc
  5. entry getc

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 3 >>

ARGF.class#gets(limit, chomp: false) -> String | nil (7.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...est.txt

# test.rb
ARGF.gets("e") # => "line"


例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"

@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs = $/) -> String | nil (7.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...est.txt

# test.rb
ARGF.gets("e") # => "line"


例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"

@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs = $/, chomp: false) -> String | nil (7.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...est.txt

# test.rb
ARGF.gets("e") # => "line"


例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"

@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs, limit) -> String | nil (7.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...est.txt

# test.rb
ARGF.gets("e") # => "line"


例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"

@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

ARGF.class#gets(rs, limit, chomp: false) -> String | nil (7.0)

ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。

...est.txt

# test.rb
ARGF.gets("e") # => "line"


例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt

# test.rb
ARGF.gets("") # => "line1\nline2\nline3\n\n"

@see Kernel.#gets, IO#gets, ARGF.class#getbyte, ARGF.class#getc...

絞り込み条件を変える

ARGF.class#readchar -> String (7.0)

ARGFから 1 文字読み込んで、その文字に対応する String を返します。EOF に 到達した時には EOFErrorを発生します。

...rorを発生します。

@raise EOFError EOFに達した時発生する

$ echo "foo" > file
$ ruby argf.rb file

ARGF.readchar # => "f"
ARGF.readchar # => "o"
ARGF.readchar # => "o"
ARGF.readchar # => "\n"
ARGF.readchar # => end of file reached (EOFError)

@see ARGF.class#getc...

Zlib::GzipReader#pos -> Integer (7.0)

現在までに展開したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。

...に注意して下さい。

require 'zlib'

Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
}

Zlib::GzipReader.open('hoge.gz'){|gz|
while c = gz.getc
printf "%c, %d\n", c, gz.pos
end
}
# 実行例
#=> h, 1
#=> o, 2
#=> g, 3
#=> e, 4
#=>
#=> , 5...

Zlib::GzipReader#tell -> Integer (7.0)

現在までに展開したデータの長さの合計を返します。 ファイルポインタの位置ではないことに注意して下さい。

...に注意して下さい。

require 'zlib'

Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
}

Zlib::GzipReader.open('hoge.gz'){|gz|
while c = gz.getc
printf "%c, %d\n", c, gz.pos
end
}
# 実行例
#=> h, 1
#=> o, 2
#=> g, 3
#=> e, 4
#=>
#=> , 5...
<< < 1 2 3 >>