るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Kernel.#test(cmd, file) -> bool | Time | Integer | nil (18160.0)

単体のファイルでファイルテストを行います。

...ルでファイルテストを行います。

@
param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@
param file テストするファイルのパス...
...を表す文字列か IO オブジェクトを指定します。
@
return 下表に特に明記していないものは、真偽値を返します。

以下は cmd として指定できる文字リテラルとその意味です。

: ?r
ファイルを実効 uid で読むことができる
: ?w...
...me
: ?A
ファイルの最終アクセス時刻を返す -> Time
: ?C
ファイルの inode 変更時刻を返す -> Time

//emlist[例][ruby]{
IO.write("testfile", "test")
test
("r", "testfile") # => true
test
("s", "testfile") # => 4
test
("M", "testfile") # => 2018-03-31 07:38:40 +0900
//}...

Kernel.#test(cmd, file1, file2) -> bool (18160.0)

2ファイル間のファイルテストを行います。

...間のファイルテストを行います。

@
param cmd 以下に示す文字リテラル、文字列、あるいは同じ文字を表す数値
です。文字列の場合はその先頭の文字だけをコマンドとみなします。
@
param file1 テストするファイルのパス...
...を表す文字列か IO オブジェクトを指定します。
@
param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@
return 真偽値を返します。

以下は cmd として指定できる文字リテラルとその意味です。

:...
...?-
ファイル1とファイル2が同一のファイルである

//emlist[例][ruby]{
IO.write("testfile1", "test1")
IO.write("testfile2", "test2")
%w(= < > -).each do |e|
result = test(e, "testfile1", "testfile2")
puts "#{e}: #{result}"
end
//}

# => =: true
# => <: false
# => >: false
#...

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (182.0)

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

...ます。

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

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

@
param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

//emlist[例][ruby]{
def test1(start, le...
...f test2(start, length)
test
1(start, length)
end

def test3(start, length)
test
2(start, length)
end

caller_locations # => []
test
3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test...
.../user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@
see T...

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

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

...ます。

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

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

@
param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。

//emlist[例][ruby]{
def test1(start, le...
...f test2(start, length)
test
1(start, length)
end

def test3(start, length)
test
2(start, length)
end

caller_locations # => []
test
3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test...
.../user/test.rb", "/Users/user/test.rb"]
test
3(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test
3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@
see T...

Kernel.#lambda -> Proc (122.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE...
...が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

@
raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block...
...lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続きを中断して値を返す

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャンプし値を返すに...

絞り込み条件を変える

Kernel.#lambda { ... } -> Proc (122.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE...
...が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

@
raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block...
...lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続きを中断して値を返す

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャンプし値を返すに...

Kernel.#proc -> Proc (122.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE...
...が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

@
raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block...
...lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続きを中断して値を返す

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャンプし値を返すに...

Kernel.#proc { ... } -> Proc (122.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...ない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE...
...が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

@
raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block...
...lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続きを中断して値を返す

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャンプし値を返すに...

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

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

...い場合は、
このメソッドは以下と同じです。

//emlist[][ruby]{
$stderr.puts(*message) if !$VERBOSE.nil? && !message.empty?
nil
//}

@
param message 出力するオブジェクトを任意個指定します。
@
param uplevel いくつ前の呼び出し元のファイル名と行番...
...しません。
@
param category 警告のカテゴリを指定します。サポートされている category については Warning.[] を参照してください。
@
raise IOError 標準エラー出力が書き込み用にオープンされていなければ発生します。
@
raise Errno::EXXX...
...[例][ruby]{
warn "caution!" #=> caution!
$VERBOSE = 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 messa...

Kernel.#lambda { ... } -> Proc (98.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...proc without lambda instead」
を出力します。

@
raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続き...
...それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。


//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:bloc...
...制限です。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel
.#lambda と Proc.new はどちらも Proc...
...proc without lambda instead」
を出力します。

@
raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
proc(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続き...

絞り込み条件を変える

Kernel.#proc { ... } -> Proc (98.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...proc without lambda instead」
を出力します。

@
raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続き...
...それ以外では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。


//emlist[例][ruby]{
def foo
f = Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:bloc...
...制限です。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel
.#lambda と Proc.new はどちらも Proc...
...proc without lambda instead」
を出力します。

@
raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
proc(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@
see Proc,Proc.new

===[a:should_use_next] 手続き...

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

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

...い場合は、
このメソッドは以下と同じです。

//emlist[][ruby]{
$stderr.puts(*message) if !$VERBOSE.nil? && !message.empty?
nil
//}

@
param message 出力するオブジェクトを任意個指定します。
@
param uplevel いくつ前の呼び出し元のファイル名と行番...
...します。 nil の場合は表示しません。
@
raise IOError 標準エラー出力が書き込み用にオープンされていなければ発生します。
@
raise Errno::EXXX 出力に失敗した場合に発生します。

//emlist[例][ruby]{
warn "caution!" #=> caution!
$VERBOSE = nil
war...
...
//}

//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
//}


@
see Warning#warn, $stderr,$VERBOSE...

Kernel.#chomp(rs = $/) -> String (80.0)

$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。

...す。

@
param rs 末尾から削除する改行コードを指定します。

//emlist[例: ruby -n で "test" を入力][ruby]{
$_ # => "test\n"
chomp # => "test"
//}

//emlist[例: ruby -n で "test," を入力し、 rs に "," を指定][ruby]{
$_ # => "test\n"
cho...
...mp # => "test,"
chomp(",") # => "test"
//}

@
see String#chomp,$_,$/...
<< 1 2 > >>