るりまサーチ

最速Rubyリファレンスマニュアル検索!
500件ヒット [1-100件を表示] (0.031秒)
トップページ > クエリ:nil[x] > クエリ:end[x] > 種類:モジュール関数[x]

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Etc.#endgrent -> nil (6202.0)

Etc.#getgrent によって開始された /etc/group ファイルを読む プロセスを終了させファイルを閉じます。

Etc.#getgrent によって開始された /etc/group ファイルを読む
プロセスを終了させファイルを閉じます。

@see getgrent(3)

Etc.#endpwent -> nil (6202.0)

Etc.#getpwent によって開始された /etc/passwdファイルを読む プロセスを終了させファイルを閉じます。

Etc.#getpwent によって開始された /etc/passwdファイルを読む
プロセスを終了させファイルを閉じます。

@see getpwent(3)

Kernel.#warn(*message, uplevel: nil, category: nil) -> nil (350.0)

message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。

...message を 標準エラー出力 $stderr に出力します。 $VERBOSE
フラグ が nil のときは何も出力しません。

文字列以外のオブジェクトが引数として与えられた場合には、
to_s メソッドにより文字列に変換してから出力します。

upleve...
...uts(*message) if !$VERBOSE.nil? && !message.empty?
nil

//}

@param message 出力するオブジェクトを任意個指定します。
@param uplevel いくつ前の呼び出し元のファイル名と行番号を表示するかを0以上の数値で指定します。 nil の場合は表示しま...
...RBOSE = nil
warn "caution!" # 何もしない
//}

//emlist[uplevel の例][ruby]{
def foo
warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end

foo
//...

Kernel.#warn(*message, uplevel: nil) -> nil (249.0)

message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。

...message を 標準エラー出力 $stderr に出力します。 $VERBOSE
フラグ が nil のときは何も出力しません。

文字列以外のオブジェクトが引数として与えられた場合には、
to_s メソッドにより文字列に変換してから出力します。

upleve...
...uts(*message) if !$VERBOSE.nil? && !message.empty?
nil

//}

@param message 出力するオブジェクトを任意個指定します。
@param uplevel いくつ前の呼び出し元のファイル名と行番号を表示するかを0以上の数値で指定します。 nil の場合は表示しま...
...RBOSE = nil
warn "caution!" # 何もしない
//}

//emlist[uplevel の例][ruby]{
def foo
warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end

foo
//...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (244.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end


def test2(start, length)
test1(start, length)
end


def test3(start, length)
test2(start, length)
end


caller_locations # => []
test3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `tes...

絞り込み条件を変える

Benchmark.#benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|rep| ...} -> [Benchmark::Tms] (233.0)

Benchmark::Report オブジェクトを生成し、それを引数として与えられたブロックを実行します。

...al:", ">avg:") do |x| ... end
# と同じ
Benchmark.benchmark(" "*7 + Benchmark::CAPTION,
7,
Benchmark::FORMAT,
">total:",
">avg:") do |x|

tf = x.report("for:") { for i in 1..n; a = "1"; end }
tt = x.report("times...
...:") { n.times do ; a = "1"; end }
tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }

[tf+tt+tu, (tf+tt+tu)/3]
end


#=>
#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# u...

JSON.#dump(object, io = nil, limit = nil) -> String | IO (209.0)

与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。

...=> "{\"name\":\"tanaka\",\"age\":19}"
//}

//emlist[例][ruby]{
require "json"

File.open("test.txt", "w") do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10) # => #<File:test.txt>
JSON.dump([[[[[[[[[[[]]]]]]]]]]], f, 10) # => exceed depth limit (ArgumentError)
end

//}

@see Marshal, Marshal.#dump...

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (174.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはいります。

また sec が 0 もしくは nil のときは制限時間なしで
ブロックを実行します。

@param sec タイムアウトする時間を秒数で指定します.
@param e...
...x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end

end


t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end


printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#...
...ムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end


=== 注意

timeout による割り込みは Thread によって実現されてい...

Kernel.#caller(range) -> [String] | nil (170.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス...
...caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end


def bar
foo
end


bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル...
...line = $2.to_i
method = $3
[file, line, method]
end

end


def foo
p parse_caller(caller.first)
end


def bar
foo
p parse_caller(caller.first)
end


bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ...

Kernel.#caller(start = 1) -> [String] | nil (170.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス...
...caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end


def bar
foo
end


bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル...
...line = $2.to_i
method = $3
[file, line, method]
end

end


def foo
p parse_caller(caller.first)
end


def bar
foo
p parse_caller(caller.first)
end


bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ...

絞り込み条件を変える

Kernel.#caller(start, length) -> [String] | nil (170.0)

start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。

...caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。

引数で指定した値が範囲外の場合は nil を返します。

@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得するス...
...caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end


def bar
foo
end


bar

#=> ["-:2:in `foo'", "-:10:in `bar'", "-:13:in `<main>'"]
# ["-:10:in `bar'", "-:13:in `<main>'"]
# ["-:13:in `<main>'"]
# []
# nil
//}

以下の関数は、caller の要素から [ファイル...
...line = $2.to_i
method = $3
[file, line, method]
end

end


def foo
p parse_caller(caller.first)
end


def bar
foo
p parse_caller(caller.first)
end


bar
p parse_caller(caller.first)

#=> ["-", 15, "bar"]
# ["-", 19, nil]
# nil
//}

以下は、$DEBUG が真の場合に役に立つ...
<< 1 2 3 ... > >>