るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

以下は cmd と...
...?O
ファイルの所有者が実 uid である
: ?e
ファイルが存在する
: ?z
ファイルサイズが 0 である
: ?s
ファイルサイズが 0 でない (ファイルサイズを返す、0 ならば nil) -> Integer|nil
: ?f
ファイルはプレーンファイルで...
...
: ?u
ファイルに setuid ビットがセットされている
: ?g
ファイルに setgid ビットがセットされている
: ?k
ファイルに sticky ビットがセットされている
: ?M
ファイルの最終更新時刻を返す -> Time
: ?A
ファイルの最...

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

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

...ンドとみなします。
@param file1 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@param file2 テストするファイルのパスを表す文字列か IO オブジェクトを指定します。
@return 真偽値を返します。

以下...
...イル1とファイル2が同一のファイルである

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

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

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

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

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

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

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

@param range 取得...
...Range オブジェクトを指定します。

//emlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
e
nd

def test2(start, length)
test
1(start, length)
e
nd

def test3(start, length)
test
2(st...
..., length)
e
nd

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.r...

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

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

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

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

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

@param range 取得...
...Range オブジェクトを指定します。

//emlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
e
nd

def test2(start, length)
test
1(start, length)
e
nd

def test3(start, length)
test
2(st...
..., length)
e
nd

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.r...

FileTest.#size?(file) -> Integer | nil (17209.0)

ファイルのサイズを返します。ファイルが存在しない時や ファイルのサイズが0の時には nil を返します。

...le ファイル名を表す文字列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

//emlist[例][ruby]{
IO.write("testfile", "test")
FileTest.size?("testfile") # => 4
File.dele...
...te("testfile")
FileTest.size?("testfile") # => nil
//}

@see FileTest.#size, FileTest.#zero?...

絞り込み条件を変える

FileTest.#world_readable?(path) -> Integer | nil (17203.0)

path が全てのユーザから読めるならばそのファイルのパーミッションを表す 整数を返します。そうでない場合は nil を返します。

...整数を返します。そうでない場合は nil を返します。

整数の意味はプラットフォームに依存します。

@param path パスを表す文字列を指定します。

m = FileTest.world_readable?("/etc/passwd")
"%o" % m # => "644"...

FileTest.#blockdev?(file) -> bool (17114.0)

ファイルがブロックスペシャルファイルである時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...false を返します。

@param file ファイル名を表す文字列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.bl...
...ockdev?(file)
}
# /dev/disk0
# /dev/disk0s3
# ......

FileTest.#chardev?(file) -> bool (17114.0)

ファイルがキャラクタスペシャルファイルの時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。

...e を返します。

@param file ファイル名を表す文字列か IO オブジェクトを指定します。

@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。

例:
Dir.glob("/dev/*") { |file|
puts file if FileTest.charde...
...v?(file)
}
# /dev/console
# /dev/tty
# ......

ARGF.class#inplace_mode -> String | nil (14347.0)

c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡 張子を返します。拡張子が設定されていない場合は空文字列を返します。イン プレースモードでない場合は nil を返します。

...c:ARGF#inplace で書き換えるファイルのバックアップに付加される拡
張子を返します。拡張子が設定されていない場合は空文字列を返します。イン
プレースモードでない場合は nil を返します。

Ruby 起動時の -i オプション や...
...ce_mode= で設定します。

例:
# $ echo "test" > test.txt
# $ ruby -i.bak test.rb test.txt
# $ cat test.txt # => "TEST"
# $ cat test.txt.bak # => "test"

# test.rb
ARGF.inplace_mode # => ".bak"
ARGF.each_line {|e|print e.upcase} # => "TEST"

例:
# $ echo "te...
...st" > test.txt
# $ ruby test.rb test.txt
# $ cat test.txt # => "test"

# test.rb
ARGF.inplace_mode # => nil
ARGF.each_line {|e|print e.upcase} # => "TEST"

@see d:spec/rubycmd#cmd_option, ARGF.class#inplace_mode=...

Exception#set_backtrace(errinfo) -> nil | String | [String] (14316.0)

バックトレース情報に errinfo を設定し、設定されたバックトレース 情報を返します。

...報に errinfo を設定し、設定されたバックトレース
情報を返します。

@param errinfo nil、String あるいは String の配列のいずれかを指定します。

//emlist[例][ruby]{
begin
begin
raise "inner"
rescue
raise "outer"
e
nd
rescue
$!.backtrace # =>...
...["/path/to/test.rb:5:in `rescue in <main>'", "/path/to/test.rb:2:in `<main>'"]
$!.set_backtrace(["dummy1", "dummy2"])
$!.backtrace # => ["dummy1", "dummy2"]
e
nd
//}...

絞り込み条件を変える

<< 1 2 3 ... > >>