るりまサーチ (Ruby 2.1.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.034秒)
トップページ > バージョン:2.1.0[x] > クエリ:kernel[x] > クエリ:skip[x] > ライブラリ:ビルトイン[x]

別のキーワード

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

キーワード

検索結果

Thread::Backtrace::Location (169.0)

Ruby のフレームを表すクラスです。

Ruby のフレームを表すクラスです。

Kernel.#caller_locations から生成されます。

//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end

c(0..2).map do |call|
puts call.to_s
end
//}

例1の実行結果:

caller_locations.rb:2:in `a'
caller_locations...

Thread::Backtrace::Location#to_s -> String (91.0)

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し ます。

self が表すフレームを Kernel.#caller と同じ表現にした文字列を返し
ます。

//emlist[例][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end

Foo.new(0..2).locations.map do |call|
puts call.to_s
end

# => path/to/foo.rb:5:in `initialize'
# path/to/foo...

ARGF (43.0)

スクリプトに指定した引数 (Object::ARGV を参照) をファイル名とみなして、 それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。 ARGV が空なら標準入力を対象とします。 ARGV を変更すればこのオブジェクトの動作に影響します。

スクリプトに指定した引数
(Object::ARGV を参照) をファイル名とみなして、
それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。
ARGV が空なら標準入力を対象とします。
ARGV を変更すればこのオブジェクトの動作に影響します。

//emlist[][ruby]{
while line = ARGF.gets
# do something
end
//}

は、

//emlist[][ruby]{
while argv = ARGV.shift
File.open(argv) {|file|
while line = file.gets...