112件ヒット
[1-100件を表示]
(0.081秒)
ライブラリ
- ビルトイン (57)
-
io
/ console (11) - openssl (11)
- stringio (22)
- strscan (11)
クラス
-
ARGF
. class (35) - IO (22)
- String (11)
- StringIO (22)
- StringScanner (11)
モジュール
-
OpenSSL
:: Buffering (11)
検索結果
先頭5件
-
String
# chr -> String (27255.0) -
self の最初の文字だけを含む文字列を返します。
..."
a.chr #=> "a"
//}
Ruby 1.9 で IO#getc の戻り値が Integer から String を返すように変更になりました。
Ruby 1.8 以前と1.9以降の互換性を保つために String#chr が存在します。
例:
# ruby 1.8 系では STDIN.getc が 116 を返すため Integer#chr が......呼び出される
$ echo test | ruby -e "p STDIN.getc.chr" # => "t"
# ruby 1.9 系以降では STDIN.getc が "t" を返すため String#chr が呼び出される
$ echo test | ruby -e "p STDIN.getc.chr" # => "t"
@see String#ord, Integer#chr... -
StringIO
# getc -> String | nil (21226.0) -
自身から 1 文字読み込んで、その文字を返します。 文字列の終端に到達した時には nil を返します。
...列の終端に到達した時には nil を返します。
@raise IOError 自身が読み取り不可なら発生します。
//emlist[例][ruby]{
require "stringio"
a = StringIO.new("ho")
a.getc # => "h"
a.getc # => "o"
a.getc # => nil
//}... -
StringScanner
# getch -> String | nil (15301.0) -
一文字スキャンして文字列で返します。 スキャンポインタをその後ろに進めます。 スキャンポインタが文字列の末尾を指すならnilを返します。
...//emlist[例][ruby]{
require 'strscan'
utf8 = "\u{308B 3073 3044}"
s = StringScanner.new(utf8.encode("UTF-8"))
p s.getch # => "る"
p s.getch # => "び"
p s.getch # => "い"
p s.getch # => nil
//}... -
IO
# getch -> String (12301.0) -
raw モードで一文字読み込んだ結果を返します。
raw モードで一文字読み込んだ結果を返します。 -
StringIO
# ungetc(str _ or _ int) -> nil (9136.0) -
文字列か整数で指定された str_or_int を自身に書き戻します。 nil を返します。
...ch を書き戻します。
@param str_or_int 書き戻したい文字を文字列か整数で指定します。複数の文
字を書き戻す事もできます。
@raise IOError 自身が読み込み可能でない時に発生します。
//emlist[例][ruby]{
require "stringio......"
s = StringIO.new("hoge")
s.pos = 1
s.ungetc("H")
p s.string # => "Hoge"
p s.pos # => 0
s = StringIO.new("hoge")
s.pos = 1
s.ungetc("H".ord)
p s.string # => "Hoge"
p s.pos # => 0
s = StringIO.new("hoge")
s.pos = 4
s.ungetc("HOGE")
p s.string # => "hogHOGE"
p s.pos # => 3
s =......StringIO.new("hoge")
s.pos = 8
s.ungetc("A")
p s.string # => "hoge\000\000\000A"
p s.pos # => 7
//}... -
ARGF
. class # readchar -> String (6223.0) -
ARGFから 1 文字読み込んで、その文字に対応する String を返します。EOF に 到達した時には EOFErrorを発生します。
... String を返します。EOF に
到達した時には EOFErrorを発生します。
@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... -
IO
# readchar -> String (6213.0) -
IO ポートから 1 文字読み込んで返します。 EOF に到達した時には EOFError が発生します。
...作します。
IO#getc との違いは EOF での振る舞いのみです。
@raise EOFError EOF に到達した時に発生します。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
f = File.new("testfile")
p f.readchar......#=> "い"
p f.readchar #=> "ろ"
p f.readchar #=> "は"
f.read
f.readchar #=> EOFError
@see IO#getc... -
OpenSSL
:: Buffering # ungetc(char) -> () (6206.0) -
指定した文字 char をバッファに読み戻します。
...指定した文字 char をバッファに読み戻します。
char には String か Integer を渡します。
IO#ungetc と同様です。
@param char 読み戻す文字... -
ARGF
. class # gets(limit , chomp: false) -> String | nil (209.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...ト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets # => "line1\n"
例:
# $ echo "line1\nline2\nli......t.txt
# test.rb
ARGF.gets(2) # => "li"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.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 (209.0) -
ARGFの現在位置から一行ずつ文字列として読み込みます。EOF に到達した時に は nil を返します。
...ト数
@param chomp true を指定すると各行の末尾から "\n", "\r", または "\r\n" を取り除きます。
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.txt
# test.rb
ARGF.gets # => "line1\n"
例:
# $ echo "line1\nline2\nli......t.txt
# test.rb
ARGF.gets(2) # => "li"
例:
# $ echo "line1\nline2\nline3\n\nline4\n" > test.txt
# $ ruby test.rb test.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...