るりまサーチ

最速Rubyリファレンスマニュアル検索!
343件ヒット [101-200件を表示] (0.031秒)
トップページ > モジュール:Kernel[x] > クエリ:file[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file open
  4. base file
  5. file size

種類

キーワード

検索結果

<< < 1 2 3 4 > >>

Kernel.#require_relative(relative_feature) -> bool (21.0)

現在のファイルからの相対パスで require します。

...現在のファイルからの相対パスで require します。

require File.expand_path(relative_feature, File.dirname(__FILE__))
とほぼ同じです。

Kernel
.#eval などで文字列を評価した場合に、そこから
require_relative を呼出すと必ず失敗します。

@param r...
...elative_feature ファイル名の文字列です。
@raise LoadError ロードに失敗した場合に発生します。
@see Kernel.#require

=== require と load のスコープ

ローカル変数はファイル間では共有されません。ですので、
ロードしたライブラリのロ...
...ーカル変数を
ロード元のスクリプトから直接取得することはできません。
このスコープの扱い方はKernel.#loadでも同様です。

//emlist[例][ruby]{
# ---------- some.rb -----------
$a = 1
@a = 1
A = 1
a = 1
# ---------- end some.rb -------

require 'some'
p...

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

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

...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

de...
...]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file
= $1
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

b...

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

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

...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

de...
...]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file
= $1
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

b...

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

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

...します。

@param range 取得したいスタックの範囲を示す Range オブジェクトを指定します。

@see Kernel.#set_trace_func,Kernel.#raise,
Kernel
.#caller_locations

//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end

de...
...]
を取り出して返します。

//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file
= $1
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

b...

Kernel.#set_trace_func(proc) -> Proc (15.0)

Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。

...ます。

標準添付の debug、tracer、
profile はこの組み込み関数を利用して実現されています。

=== ブロックパラメータの意味

渡す Proc オブジェクトのパラメータは
//emlist[][ruby]{
proc{|event, file, line, id, binding, klass| "..." }
//}
で、...
...への突入。
"end": クラス定義、特異クラス定義、モジュール定義の終了。
"raise": 例外の発生。
//}
: file
実行中のプログラムのソースファイル名 (文字列)。

: line
実行中のプログラムのソースファイル上の行番号 (...
...uby]{
set_trace_func lambda {|*arg|
p arg
}
class Foo
end
43.to_s

# ----結果----
# ["c-return", "..", 1, :set_trace_func, #<Binding:0xf6ceb8>, Kernel]
# ["line", "..", 4, nil, #<Binding:0x10cbcd8>, nil]
# ["c-call", "..", 4, :inherited, #<Binding:0x10cba98>, Class]
# ["c-return", "..", 4, :inhe...

絞り込み条件を変える

Kernel.#spawn(command, options={}) -> Integer (11.0)

引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。

...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。

@raise Errno::EXXX コマンドが実行できなかった場合に発生します。


@see Kernel.#system,Kernel.#exec...

Kernel.#spawn(env, command, options={}) -> Integer (11.0)

引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。

...表す Hash
@param options オプションパラメータ Hash
@raise Errno::EXXX 起動に失敗し、ruby インタプリタに制御が戻った場合に発生します。

@raise Errno::EXXX コマンドが実行できなかった場合に発生します。


@see Kernel.#system,Kernel.#exec...

Kernel$$> -> object (9.0)

標準出力です。

...標準出力です。

組み込み関数 Kernel.#print、Kernel.#puts や
Kernel
.#p などのデフォルトの出力先となります。
初期値は Object::STDOUT です。
コマンドラインオプションオプション -i を指定した場合には
読み込み元と同じ名前のフ...
...は、
以下のように $stdout に代入すれば十分です。

//emlist[例][ruby]{
# 標準出力の出力先を /tmp/foo に変更
$stdout = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stdout = STDOUT # 元に戻す
//}

自プロセスだけでなく、子プロセスの...

Kernel$$stderr -> object (9.0)

標準エラー出力です。

...標準エラー出力です。

Ruby インタプリタが出力するエラーメッセージや
警告メッセージ、Kernel.#warn の出力先となります。
初期値は Object::STDERR です。

$stderr に代入するオブジェクトには
write という名前のメソッドが定義...
...ときには、
$stderr に代入すれば十分です。

//emlist[例][ruby]{
# 標準エラー出力の出力先を /tmp/foo に変更
$stderr = File.open("/tmp/foo", "w")
puts "foo" # 出力する
$stderr = STDERR # 元に戻す
//}

自プロセスだけでなく、子プロセスの...

Kernel$$stdin -> object (9.0)

標準入力です。

...
$stdin = File.open("/tmp/foo", "r")
gets # 入力する
$stdin = STDIN # 元に戻す
//}

ただし、Kernel.#gets など、特定の組み込みメソッドは
$stdin オブジェクトにメソッドを転送して実装されています。
従って、Kernel.#gets など...
...メソッドを
正しく実装していなければいけません。

gets, readline, readlines, getc, readchar, tell, seek,
pos=, rewind, fileno, to_io, eof, each_line, each_byte,
binmode, closed?

//emlist[例][ruby]{
$stdin = Object.new
def $stdin.gets
"foo"
end
p gets() # => "fo...

絞り込み条件を変える

<< < 1 2 3 4 > >>