種類
- インスタンスメソッド (132)
- 文書 (11)
クラス
-
ARGF
. class (55) - IO (22)
- String (11)
- StringIO (22)
- StringScanner (22)
キーワード
-
get
_ byte (11) - getc (11)
- gets (33)
-
ruby 1
. 8 . 2 feature (11) - ungetbyte (22)
検索結果
先頭5件
-
IO
# getbyte -> Integer | nil (41213.0) -
IO から1バイトを読み込み整数として返します。 既に EOF に達していれば nil を返します。
...
IO から1バイトを読み込み整数として返します。
既に EOF に達していれば nil を返します。
f = File.new("testfile")
f.getbyte #=> 84
f.getbyte #=> 104... -
IO
# ungetbyte(c) -> nil (29212.0) -
指定したバイト列を書き戻します。
...い読み出し(IO#sysread など)
には影響しません。
@param c バイト列(文字列)、もしくは0から255までの整数
例:
f = File.new("testfile") #=> #<File:testfile>
b = f.getbyte #=> 0x38
f.ungetbyte(b) #=> nil
f.getbyte... -
String
# getbyte(index) -> Integer | nil (21325.0) -
index バイト目のバイトを整数で返します。
...
index バイト目のバイトを整数で返します。
index に負を指定すると末尾から数えた位置のバイト
を取り出します。
範囲外を指定した場合は nil を返します。
@param index バイトを取り出す位置
//emlist[例][ruby]{
s = "tester"
s.bytes......# => [116, 101, 115, 116, 101, 114]
s.getbyte(0) # => 116
s.getbyte(1) # => 101
s.getbyte(-1) # => 114
s.getbyte(6) # => nil
//}... -
StringIO
# getbyte -> Integer | nil (21219.0) -
自身から 1 文字読み込んで、その文字に対応する Fixnum を返します。 文字列の終端に到達した時には nil を返します。
...Fixnum を返します。
文字列の終端に到達した時には nil を返します。
@raise IOError 自身が読み取り不可なら発生します。
//emlist[例][ruby]{
require "stringio"
a = StringIO.new("ho")
a.getbyte #=> 104
a.getbyte #=> 111
a.getbyte......#=> nil
//}... -
ARGF
. class # getbyte -> Integer | nil (18255.0) -
self から 1 バイト(0..255)を読み込み整数として返します。 既に EOF に達していれば nil を返します。
...self から 1 バイト(0..255)を読み込み整数として返します。
既に EOF に達していれば nil を返します。
ARGF はスクリプトに指定した引数(Object::ARGV を参照) をファイル名
とみなして、それらのファイルを連結した 1 つの仮想フ......$ echo "foo" > file1
$ echo "bar" > file2
$ ruby argf.rb file1 file2
ARGF.getbyte # => 102
ARGF.getbyte # => 111
ARGF.getbyte # => 111
ARGF.getbyte # => 10
ARGF.getbyte # => 98
ARGF.getbyte # => 97
ARGF.getbyte # => 114
ARGF.getbyte # => 10
ARGF.getbyte # => nil
@see ARGF.cla... -
StringScanner
# getbyte -> String | nil (18207.0) -
1 バイトスキャンして文字列で返します。 スキャンポインタをその後ろに進めます。 スキャンポインタが文字列の末尾を指すなら nil を返します。
...の末尾を指すなら nil を返します。
StringScanner#getbyte は将来のバージョンで削除される予定です。
代わりに StringScanner#get_byte を使ってください。
//emlist[例][ruby]{
require 'strscan'
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode("......EUC-JP"))
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xEB"
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xD3"
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xA4"
p s.get_byte #=> nil
//}... -
StringIO
# ungetbyte(char) -> nil (9200.0) -
指定された char を読み戻します。
...指定された char を読み戻します。
2バイト以上の読み戻しは保証されません。
@param char 読み戻したい1文字かそのコードポイントを指定します。
@see IO#ungetbyte... -
StringScanner
# get _ byte -> String | nil (3107.0) -
1 バイトスキャンして文字列で返します。 スキャンポインタをその後ろに進めます。 スキャンポインタが文字列の末尾を指すなら nil を返します。
...の末尾を指すなら nil を返します。
StringScanner#getbyte は将来のバージョンで削除される予定です。
代わりに StringScanner#get_byte を使ってください。
//emlist[例][ruby]{
require 'strscan'
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode("......EUC-JP"))
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xEB"
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xD3"
p s.get_byte #=> "\xA4"
p s.get_byte #=> "\xA4"
p s.get_byte #=> nil
//}... -
ARGF
. class # getc -> String | nil (106.0) -
self から 1 文字読み込んで返します。EOF に到達した時には nil を返します。
...self から 1 文字読み込んで返します。EOF に到達した時には nil を返します。
ARGF はスクリプトに指定した引数(Object::ARGV を参照) をファイル名
とみなして、それらのファイルを連結した 1 つの仮想ファイルを表すオブジェ......echo "foo" > file1
$ echo "bar" > file2
$ ruby argf.rb file1 file2
ARGF.getc # => "f"
ARGF.getc # => "o"
ARGF.getc # => "o"
ARGF.getc # => "\n"
ARGF.getc # => "b"
ARGF.getc # => "a"
ARGF.getc # => "r"
ARGF.getc # => "\n"
ARGF.getc # => nil
@see ARGF.class#getbyte, ARGF.class#... -
ARGF
. class # gets(limit) -> String | nil (106.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...nil を返します。
@param rs 行の区切りを文字列で指定します。rs に nil を指定すると行区切
りなしとみなします。空文字列 "" を指定すると連続する改行を行
の区切りとみなします(パラグラフモード)。
@param li......mit 最大の読み込みバイト数
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets # => "line1\n"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets(2......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...