るりまサーチ

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

別のキーワード

  1. rss source
  2. _builtin source_location
  3. _builtin source_encoding
  4. socket ip_block_source
  5. socket ip_unblock_source

ライブラリ

クラス

キーワード

検索結果

Proc#source_location -> [String, Integer] | nil (21138.0)

ソースコードのファイル名と行番号を配列で返します。

...by]{
# /path/to/target.rb を実行
p
roc {}.source_location # => ["/path/to/target.rb", 1]
p
roc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc {}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}

@see Method#source_location...

Binding#source_location -> [String, Integer] (18114.0)

self の Ruby のソースファイル名と行番号を返します。

...self の Ruby のソースファイル名と行番号を返します。

d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。

//emlist[例][ruby]{
p
binding.source_location # => ["test.rb", 1]
//}...

Module#const_source_location(name, inherited = true) -> [String, Integer] (6234.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数...
...end

p
B.const_source_location('C4') # => ["test.rb", 12]
p
B.const_source_location('C3') # => ["test.rb", 7]
p
B.const_source_location('C1') # => ["test.rb", 2]

p
B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない

p
A...
....const_source_location('C2') # => ["test.rb", 16] -- 最後に定義された位置を返す

p
Object.const_source_location('B') # => ["test.rb", 10] -- Object はトップレベルの定数を検索する
p
Object.const_source_location('A') # => ["test.rb", 1] -- クラスが...

Method#inspect -> String (6149.0)

self を読みやすい文字列として返します。

...の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2...
...は Method#source_location を表します。
source_location
が nil の場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end

p
Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p
Bar.new.m...
...end
end
p
obj.method(:foo) # => #<Method: "".foo() foo.rb:4>

# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p
Foo.method(:foo) # => #<Method: Foo.foo() foo.rb:11>

# スーパークラスのクラスメソッド
class Bar < Foo
end
p
Bar.metho...

Method#to_s -> String (3049.0)

self を読みやすい文字列として返します。

...の文字列を返します。

#<Method: klass1(klass2)#method(arg) foo.rb:2> (形式1)

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクトの生成
元となったクラス/モジュール名です。

klass2...
...は Method#source_location を表します。
source_location
が nil の場合には付きません。

//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end

p
Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p
Bar.new.m...
...end
end
p
obj.method(:foo) # => #<Method: "".foo() foo.rb:4>

# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p
Foo.method(:foo) # => #<Method: Foo.foo() foo.rb:11>

# スーパークラスのクラスメソッド
class Bar < Foo
end
p
Bar.metho...

絞り込み条件を変える