るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

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

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

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

@see Method...
...#source_location...

UnboundMethod#source_location -> [String, Integer] | nil (32227.0)

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

...nil を返します。

//emlist[例][ruby]{
require 'time'

Time.instance_method(:zone).source_location # => nil
Time.instance_method(:httpdate).source_location # => ["/Users/user/.rbenv/versions/2.4.3/lib/ruby/2.4.0/time.rb", 654]
//}

@see Proc#source_location, Method#source_location...

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

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

...す。

@see Proc#source_location

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
e
nd
# ----- 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...

Binding#source_location -> [String, Integer] (32209.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] (20269.0)

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

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

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義され...
...た定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソースコードのファイル名と行番号を配列で返します。
指定した定数が見つからない場合は nil を返します。
定数は見つかったがソ...
...す。

//emlist[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
e
nd

module M # line 6
C3 = 3
e
nd

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

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

p B.const_source_location('C4')...

絞り込み条件を変える

Method#inspect -> String (14114.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...
method は、メソッド名を表します。

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

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

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 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異...

Method#to_s -> String (11014.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...
method は、メソッド名を表します。

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

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

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 が同じ場合は以下の形式になります。
#<Method: klass1#method() foo.rb:2> (形式2)

特異...