種類
- インスタンスメソッド (485)
- モジュール関数 (376)
- クラス (99)
- 特異メソッド (97)
- 変数 (22)
クラス
- Array (11)
- Binding (11)
- Data (8)
- Exception (33)
- Hash (11)
- IO (11)
- Integer (22)
- MatchData (48)
- Module (102)
- NameError (22)
- NoMethodError (11)
- Object (33)
- Proc (18)
- Regexp (22)
- String (44)
- Struct (44)
- Thread (65)
-
Thread
:: Backtrace :: Location (22) - ThreadGroup (11)
- TracePoint (11)
- UnboundMethod (11)
キーワード
-
$ @ (11) -
$ ` (11) - % (11)
- Enumerator (11)
- Fiber (11)
- Integer (11)
- Location (11)
- NameError (11)
- NoMethodError (11)
- Proc (11)
- RegexpError (11)
- Status (11)
- Symbol (11)
- [] (15)
- args (11)
- backtrace (22)
-
backtrace
_ locations (33) - begin (11)
- bind (11)
- byteoffset (4)
- caller (33)
-
caller
_ locations (22) - chr (22)
-
default
_ proc= (11) - dump (22)
- enclose (11)
- end (11)
- exec (55)
- fail (33)
- format (11)
- freeze (11)
- include (11)
- inspect (22)
- lambda (17)
-
local
_ variable _ set (11) - match (22)
-
module
_ function (19) - name (11)
- new (55)
-
object
_ id (11) - offset (22)
- private (23)
- proc (18)
- public (23)
-
public
_ class _ method (15) -
public
_ instance _ method (11) -
public
_ method (11) - putc (11)
- raise (33)
-
report
_ on _ exception (16) -
report
_ on _ exception= (16) -
require
_ relative (11) -
set
_ backtrace (11) - spawn (44)
- sprintf (11)
- squeeze (11)
- squeeze! (11)
- sysseek (11)
- system (44)
-
to
_ s (22) - tr (11)
- transpose (11)
検索結果
先頭5件
-
Kernel
. # `(command) -> String (26158.0) -
command を外部コマンドとして実行し、その標準出力を文字列として 返します。このメソッドは `command` の形式で呼ばれます。
...command を外部コマンドとして実行し、その標準出力を文字列として
返します。このメソッドは `command` の形式で呼ばれます。
引数 command に対しダブルクォートで囲まれた文字列と同様の解釈と式展開を行った後、
コマンド......必要がなく、単にコマンドを実行したいだけなら
Kernel.#system を使います。特に端末を制御するコマンドでは
`command` は失敗するかもしれません。
d:spec/literal#command も参照。
@param command コマンドとして実行する引数です。そ......返します。
@raise Errno::EXXX コマンドを実行できないときや失敗した場合に発生します。
//emlist[例][ruby]{
puts `ruby -v` #=> ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
puts $?.inspect #=> #<Process::Status: pid=3580,exited(0)>
//}
@see Kernel.#system,Kernel... -
Kernel
$ $ ` -> String | nil (14102.0) -
現在のスコープで最後に成功した正規表現のパターンマッチでマッチした 部分より前の文字列です。 最後のマッチが失敗していた場合には nil となります。
...す。
この変数はローカルスコープかつスレッドローカル、読み取り専用です。
Ruby起動時の初期値は nil です。
//emlist[例][ruby]{
str = '<p><a href="http://example.com">example.com</a></p>'
if %r[<a href="(.*?)">(.*?)</a>] =~ str
p $`
end
#=> "<p>"
//}... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (8032.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...rs/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 (8032.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...rs/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... -
Thread
:: Backtrace :: Location (8032.0) -
Ruby のフレームを表すクラスです。
...(skip)
b(skip)
end
c(0..2).map do |call|
puts call.to_s
end
//}
例1の実行結果:
caller_locations.rb:2:in `a'
caller_locations.rb:5:in `b'
caller_locations.rb:8:in `c'
//emlist[例2][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller......cations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}
例2の実行結果:
init.rb:4:in `initialize'
init.rb:8:in `new'
init.rb:8:in `<main>'
=== 参考
* Ruby VM アドベントカレンダー #4 vm_backtrace.c: https://www.atdot.net/~ko1/diary/201212.ht... -
Data
. [](**kwargs) -> Data (8026.0) -
(このメソッドは Data のサブクラスにのみ定義されています) 値オブジェクトを生成して返します。
...# => in `initialize': missing keyword: :y (ArgumentError)
Point.new(1, 2, 3) # => in `new': wrong number of arguments (given 3, expected 0..2) (ArgumentError)
Point.new(x: 1) # => in `initialize': missing keyword: :y (ArgumentError)
Point.new(x: 1, y: 2, z: 3) # => in `initia... -
Data
. [](*args) -> Data (8026.0) -
(このメソッドは Data のサブクラスにのみ定義されています) 値オブジェクトを生成して返します。
...# => in `initialize': missing keyword: :y (ArgumentError)
Point.new(1, 2, 3) # => in `new': wrong number of arguments (given 3, expected 0..2) (ArgumentError)
Point.new(x: 1) # => in `initialize': missing keyword: :y (ArgumentError)
Point.new(x: 1, y: 2, z: 3) # => in `initia... -
Data
. new(**kwargs) -> Data (8026.0) -
(このメソッドは Data のサブクラスにのみ定義されています) 値オブジェクトを生成して返します。
...# => in `initialize': missing keyword: :y (ArgumentError)
Point.new(1, 2, 3) # => in `new': wrong number of arguments (given 3, expected 0..2) (ArgumentError)
Point.new(x: 1) # => in `initialize': missing keyword: :y (ArgumentError)
Point.new(x: 1, y: 2, z: 3) # => in `initia... -
Data
. new(*args) -> Data (8026.0) -
(このメソッドは Data のサブクラスにのみ定義されています) 値オブジェクトを生成して返します。
...# => in `initialize': missing keyword: :y (ArgumentError)
Point.new(1, 2, 3) # => in `new': wrong number of arguments (given 3, expected 0..2) (ArgumentError)
Point.new(x: 1) # => in `initialize': missing keyword: :y (ArgumentError)
Point.new(x: 1, y: 2, z: 3) # => in `initia... -
Thread
# backtrace -> [String] | nil (8026.0) -
スレッドの現在のバックトレースを返します。
...def m1
sleep 5
end
def m2
m1
end
end
th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]
th.kill
th.backtrace # => nil
//}... -
Binding
# local _ variable _ set(symbol , obj) (8020.0) -
引数 symbol で指定した名前のローカル変数に引数 obj を設定します。
...{
def foo
a = 1
bind = binding
bind.local_variable_set(:a, 2) # set existing local variable `a'
bind.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.local_variable_get(:b)... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (8020.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...et_exception
return begin
yield
rescue => e
e
end
end
e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get_exception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Kernel
. # Integer(arg , base = 0) -> Integer (8020.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...と末尾の空白類は無視される
p Integer("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}
@see...