るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. bigdecimal to_r

ライブラリ

クラス

検索結果

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

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

... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。


//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 (24325.0)

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

... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。

//emlist[例][ruby]{
r
equire 'time'

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

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

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

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

...続オブジェクトが ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。

@see Proc#source_location

//emlist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
def foo; end
end
# ----- end of /tmp/foo.rb ----

r
equire '/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] (24307.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] (12367.0)

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

...す。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソース...
...][ruby]{
# test.rb:
class A # line 1
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",...
...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] -- 最後...

絞り込み条件を変える

NEWS for Ruby 2.7.0 (3348.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.7.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.6.0 以降の変更

=== 言語仕様の変更

==== パターンマッチ

* パターンマッチが実験的機能として導入されました。 14912

//emlist[][ruby]{
case [0, [1, 2, 3]]
in [a, [b...
...を取得するModule#const_source_location
メソッドが追加されました。 10771
* 通常の引数分解でキーワード引数を渡すようにメソッドに印をつける
Module#ruby2_keywordsを追加しました。
古いRubyと互換性のある方法...

NEWS for Ruby 2.6.0 (3072.0)

NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.6.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...ルか bugs.ruby-lang.org の issue を参照してください。

== 2.5.0 以降の変更

=== 言語仕様の変更

* $SAFE はプロセスグローバルで扱われることになると共に、0以外を設定した後に0に戻せるようになりました。 14250

* Refinements が...
...。 15143
* 別名
* Array#filter が Array#select の別名として追加されました。 13784
* Array#filter! が Array#select! の別名として追加されました。 13784

* Binding
* 新規メソッド
* Binding#source_location 追加 14230
* binding...

Method#inspect -> String (212.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...します。

arg は引数を表します。
「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)...
...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: obj.method() foo.rb...

Method#to_s -> String (212.0)

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

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

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

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

klass1 は、Method#inspect では、レシーバのクラス名、
UnboundMethod#inspect では、UnboundMethod オブジェクト...
...します。

arg は引数を表します。
「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)...
...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: obj.method() foo.rb...