るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

キーワード

検索結果

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

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

...@see Proc#source_location

//emlist[例][ruby]{
# ------- /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>
m.source_location # => ["/tmp/foo.rb", 2]

method(:puts).source_location # => nil
//}...

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

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

...C1 = 1
C2 = 2
end


module M # line 6
C3 = 3
end


class B < A # line 10
include M
C4 = 4
end


class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end


p B.const_source_location('C4') # => ["test.rb", 12]
p B.const_source_location('C3')...
...st_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...
...検索する
p Object.const_source_location('A') # => ["test.rb", 1] -- クラスが再定義された場合は最初の定義位置を返す

p B.const_source_location('A') # => ["test.rb", 1] -- Object を継承している為
p M.const_source_location('A') # => ["test...

Method#inspect -> String (85.0)

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

...数を表します。
「foo.rb:2」は 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: B...
...ef foo
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...
....method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end

end


class <<obj
include Baz
end

p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...

Method#to_s -> String (85.0)

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

...数を表します。
「foo.rb:2」は 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: B...
...ef foo
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...
....method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>

# 以下は(形式1)の出力になる
module Baz
def baz
end

end


class <<obj
include Baz
end

p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:23>
//}

@see Object#inspect...