るりまサーチ

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

別のキーワード

  1. kernel system
  2. kernel exec
  3. kernel spawn
  4. kernel open
  5. kernel raise

検索結果

<< 1 2 3 ... > >>

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

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

...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 (27124.0)

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

...ァイル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
# => -: fals...

Shell#test(command, file1, file2 = nil) -> bool | Time | Integer | nil (15157.0)

Kernel.#test や FileTest のメソッドに処理を委譲します。

...
Kernel
.#test や FileTest のメソッドに処理を委譲します。

@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。

@para...
...ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true

@see Kernel.#test, FileTest...

Shell::CommandProcessor#test(command, file1, file2 = nil) -> bool | Time | Integer | nil (15157.0)

Kernel.#test や FileTest のメソッドに処理を委譲します。

...
Kernel
.#test や FileTest のメソッドに処理を委譲します。

@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。

@para...
...ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true

@see Kernel.#test, FileTest...

Shell::Filter#test(command, file1, file2 = nil) -> bool | Time | Integer | nil (15157.0)

Kernel.#test や FileTest のメソッドに処理を委譲します。

...
Kernel
.#test や FileTest のメソッドに処理を委譲します。

@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。

@para...
...ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true

@see Kernel.#test, FileTest...

絞り込み条件を変える

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

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

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def 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.rb", "/Users/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 Thread::Backtrace::Location, Kernel.#caller...

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

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

...][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def 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.rb", "/Users/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 Thread::Backtrace::Location, Kernel.#caller...

Kernel#create_makefile(target, srcprefix = nil) -> true (9048.0)

@todo

...@todo

Kernel
#have_library などの各種検査の結果を元に、拡張ライブラリを
ビルドするための Makefile を生成します。

extconf.rb は普通このメソッドの呼び出しで終ります。

@param target ターゲットとなる拡張ライブラリの名前を指...
...例えば、'test/foo' を指定した場合、拡張ライブラリは
'test' ディレクトリにインストールされます。この拡張ライブ
ラリを Ruby スクリプトから使用するときは
"require 'test/foo'" とする必要...
...rb
test
/
foo.c

このようにします。

require 'mkmf'
create_makefile('test/foo', 'test')

このようにして作った Makefile で 'make install' すると拡張ライブラリは、
以下のパスにインストールされます。

/path/to/ruby/sitearchdir/test/...

Kernel.#chop -> String (9048.0)

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

...コピーの方を更新し、
$_ に再代入します。

//emlist[例][ruby]{
$_ = "test\r\n"
$_ # => "test\r\n"
chop # => "test"
$_ = "test\n"
$_ # => "test\n"
chop # => "test"
$_ = "test"
$_ # => "test"
chop # => "tes"
//}

@see String#chop,$_...

Kernel.#lambda -> Proc (9048.0)

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

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

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

Kernel
.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手...
...。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。

Kernel
.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で...
...ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end

def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end

def test_block
tap { return :from_block }
return :from_method
end

p test_proc() #=> :from_proc
p test_lambda()...

絞り込み条件を変える

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

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

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

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

Kernel
.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手...
...。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。

Kernel
.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で...
...ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end

def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end

def test_block
tap { return :from_block }
return :from_method
end

p test_proc() #=> :from_proc
p test_lambda()...
<< 1 2 3 ... > >>