るりまサーチ

最速Rubyリファレンスマニュアル検索!
39件ヒット [1-39件を表示] (0.035秒)
トップページ > クラス:Method[x] > クエリ:source_location[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

Method#source_location -> [String, Integer] | nil (18120.0)

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

...E** [m:Proc#source_location]

```ruby title="例"
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----

require '/tmp/foo'

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
p m.source_location # => ["/tmp/foo.rb", 2]

p method(:puts).source_location # => nil
`...

Method#inspect -> String (13.0)

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

...以下の形式の文字列を返します。

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

klass1 は、[m:Method#inspect] では、レシーバのクラス名、
[m:UnboundMethod#inspect] では、[c:UnboundMethod] オブジェクトの生成元となったクラス/...
...のメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は [m:Method#source_location] を表します。
source_location
が nil の場合には付きません。

```ruby title="例"
module...
...bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
```

klass1 と klass2 が同じ場合は以下の形式になります。

```text
#<Method: klass1#method() foo.rb:2> (形...

Method#to_s -> String (13.0)

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

...以下の形式の文字列を返します。

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

klass1 は、[m:Method#inspect] では、レシーバのクラス名、
[m:UnboundMethod#inspect] では、[c:UnboundMethod] オブジェクトの生成元となったクラス/...
...のメソッドを定義しているクラス/モジュール名、
method
は、メソッド名を表します。

arg は引数を表します。
「foo.rb:2」は [m:Method#source_location] を表します。
source_location
が nil の場合には付きません。

```ruby title="例"
module...
...bar(a, b)
end
end

p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Bar#bar(a, b) test.rb:8>
```

klass1 と klass2 が同じ場合は以下の形式になります。

```text
#<Method: klass1#method() foo.rb:2> (形...