種類
- インスタンスメソッド (92)
- 定数 (33)
- 特異メソッド (9)
クラス
-
ARGF
. class (9) - Array (50)
- Data (2)
- IO (11)
- Struct (7)
モジュール
- Enumerable (22)
- Process (33)
キーワード
-
CLOCK
_ MONOTONIC (11) -
CLOCK
_ PROCESS _ CPUTIME _ ID (11) -
CLOCK
_ REALTIME (11) -
collect
_ concat (11) - combination (11)
- cycle (11)
- define (2)
- filter! (6)
-
flat
_ map (11) - new (7)
- permutation (11)
-
read
_ nonblock (20) - select! (11)
検索結果
先頭5件
-
Process
:: CLOCK _ MONOTONIC -> Integer | Symbol (12302.0) -
Process.#clock_gettime で使われます。
...Process.#clock_gettime で使われます。
システムによっては :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC です。
システムによっては定義されていません。... -
Process
:: CLOCK _ PROCESS _ CPUTIME _ ID -> Integer | Symbol (12302.0) -
Process.#clock_gettime で使われます。
...Process.#clock_gettime で使われます。
システムによっては :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID です。
システムによっては定義されていません。... -
Process
:: CLOCK _ REALTIME -> Integer | Symbol (12302.0) -
Process.#clock_gettime で使われます。
...Process.#clock_gettime で使われます。
システムによっては :GETTIMEOFDAY_BASED_CLOCK_REALTIME です。
システムによっては定義されていません。... -
IO
# read _ nonblock(maxlen , outbuf = nil , exception: true) -> String | Symbol | nil (9402.0) -
IO をノンブロッキングモードに設定し、 その後で read(2) システムコールにより 長さ maxlen を上限として読み込み、文字列として返します。 EAGAIN, EINTR などは Errno::EXXX 例外として呼出元に報告されます。
...
IO をノンブロッキングモードに設定し、
その後で read(2) システムコールにより
長さ maxlen を上限として読み込み、文字列として返します。
EAGAIN, EINTR などは Errno::EXXX 例外として呼出元に報告されます。
発生した例外 がErr......no::EAGAIN、 Errno::EWOULDBLOCK である場合は、
その例外オブジェクトに IO::WaitReadable が Object#extend
されます。
なお、バッファが空でない場合は、read_nonblock はバッファから読み込みます。この場合、read(2) システムコールは呼ば......れません。
このメソッドはノンブロッキングモードにする点を除いて IO#readpartial と
同じであることに注意してください。
バイナリ読み込みメソッドとして動作します。
既に EOF に達していれば EOFError が発生します。た... -
Array
# filter! {|item| block } -> self | nil (9302.0) -
ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。 変更があった場合は self を、 変更がなかった場合には nil を返します。
...nil を返します。
//emlist[例][ruby]{
a = %w{ a b c d e f }
a.select! {|v| v =~ /[a-z]/ } # => nil
a # => ["a", "b", "c", "d", "e", "f"]
//}
ブロックが与えられなかった場合は、自身と select! から生成した
Enumerator オブジェクトを返します。
@see Array#......keep_if, Array#reject!... -
Array
# combination(n) {|c| block } -> self (9202.0) -
サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。
...合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_a......2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] : no combinations of length 5
/......た配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # => [1,2,3,4]
result #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
//}
@see Array#permutation, Array#repeated_combination... -
Array
# permutation(n = self . length) { |p| block } -> self (9202.0) -
サイズ n の順列をすべて生成し,それを引数としてブロックを実行します。
...場合は to_int メソッドによる暗
黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = [1, 2, 3]
a.permutation.to_a......a.permutation(1).to_a #=> [[1],[2],[3]]
a.permutation(2).to_a #=> [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
a.permutation(3).to_a #=> [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
a.permutation(0).to_a #=> [[]]: one permutation of length 0
a.permutation(4).to_a #=> [] : no permutations of len......した配列の各要素を引数としてブロックを実
行して self を返します。
//emlist[例][ruby]{
a = [1, 2, 3]
result = []
a.permutation(2) {|e| result << e} # => [1,2,3]
result # => [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]]
//}
@see Array#combination, Array#repeated_permutation... -
ARGF
. class # read _ nonblock(maxlen , outbuf = nil , exception: true) -> String | Symbol | nil (6402.0) -
処理中のファイルからノンブロッキングモードで最大 maxlen バイト読み込みます。 詳しくは IO#read_nonblock を参照してください。
...くは IO#read_nonblock を参照してください。
ARGF.class#read などとは違って複数ファイルを同時に読み込むことはありません。
@param maxlen 読み込む長さの上限を整数で指定します。
@param outbuf 読み込んだデータを格納する String オ......ブジェクトを指定します。
@param exception 読み込み時に Errno::EAGAIN、
Errno::EWOULDBLOCK が発生する代わりに
:wait_readable を返すかどうかを指定します。また、false
を指定した場合は既に EOF に......達していれば
EOFError の代わりに nil を返します。
@see ARGF.class#readpartial... -
Array
# cycle(n=nil) {|obj| block } -> nil (6402.0) -
配列の全要素を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
...を n 回(nilの場合は無限に)繰り返しブロックを呼びだします。
ブロックを省略した場合は Enumerator を返します。
@param n 繰り返したい回数を整数で指定します。
整数以外のオブジェクトを指定した場合は to_int メソッ......黙の型変換を試みます。
@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。
//emlist[例][ruby]{
a = ["a", "b", "c"]
a.cycle {|x| puts x } # print, a, b, c, a, b, c,.. forever.
//}... -
Data
. define(*args) {|subclass| block } -> Class (6232.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...ドが定義されています。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}
メンバの値を書き換えることはできません。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)......ンマッチに利用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
e......end
end
def fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end
p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFo... -
Array
# select! {|item| block } -> self | nil (6202.0) -
ブロックが真を返した要素を残し、偽を返した要素を自身から削除します。 変更があった場合は self を、 変更がなかった場合には nil を返します。
...nil を返します。
//emlist[例][ruby]{
a = %w{ a b c d e f }
a.select! {|v| v =~ /[a-z]/ } # => nil
a # => ["a", "b", "c", "d", "e", "f"]
//}
ブロックが与えられなかった場合は、自身と select! から生成した
Enumerator オブジェクトを返します。
@see Array#......keep_if, Array#reject!...