ライブラリ
- ビルトイン (262)
-
minitest
/ unit (2) - mkmf (11)
- rake (11)
- shell (12)
-
shell
/ command-processor (12) -
shell
/ filter (12) -
test
/ unit (1)
クラス
-
ARGF
. class (33) - File (33)
- IO (11)
- Shell (12)
-
Shell
:: CommandProcessor (12) -
Shell
:: Filter (12) - Thread (22)
モジュール
- FileTest (11)
- Kernel (163)
-
MiniTest
:: Assertions (2) -
Test
:: Unit (1)
キーワード
-
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Proc (11)
- Rubyの起動 (3)
- Ruby用語集 (11)
- [] (18)
-
assert
_ throws (1) -
backtrace
_ locations (22) -
caller
_ locations (22) - chomp (11)
- chop (11)
-
create
_ makefile (11) - desc (11)
- gets (33)
- gsub (33)
- identical? (11)
- lambda (17)
-
minitest
/ autorun (11) -
minitest
/ unit (1) - new (11)
- open (22)
- proc (18)
- puts (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 4 feature (11) -
setup
_ argv (1) - skip (1)
- warn (7)
- クラス/メソッドの定義 (11)
- 手続きオブジェクトの挙動の詳細 (11)
検索結果
先頭5件
- Kernel
. # test(cmd , file) -> bool | Time | Integer | nil - Kernel
. # test(cmd , file1 , file2) -> bool - Shell
# test(command , file1 , file2 = nil) -> bool | Time | Integer | nil - Shell
:: CommandProcessor # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil - Shell
:: Filter # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil
-
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)
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 `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(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"]
test3(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)
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 `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(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"]
test3(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()...