るりまサーチ

最速Rubyリファレンスマニュアル検索!
96件ヒット [1-96件を表示] (0.028秒)
トップページ > クエリ:method[x] > クエリ:main[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. irb/input-method gets
  2. irb/input-method new
  3. _builtin define_method
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

ライブラリ

キーワード

検索結果

NoMethodError#args -> [object] (3013.0)

メソッド呼び出しに使われた引数を配列で返します。

...メソッド呼び出しに使われた引数を配列で返します。

例:

begin
foobar(1,2,3)
rescue NoMethodError
p $!
p $!.name
p $!.args
end

# => #<NoMethodError: undefined method `foobar' for main:Object>
:foobar
[1, 2, 3]...

Object#respond_to?(name, include_all = false) -> bool (55.0)

オブジェクトがメソッド name を持つとき真を返します。

...def main
start
template_method
finish
end

def start
puts "start"
end

def template_method
raise NotImplementedError.new
end

def finish
puts "finish"
end
end

class ImplTemplateMethod
include Template
def template_method
"implement template_method"...
...mplateMethod
include Template

# not implement template_method
end

puts ImplTemplateMethod.new.respond_to?(:template_method) # => true
# NotImplementedError が発生しているが、Rubyによる実装部のため true を返す
puts NotImplTemplateMethod.new.respond_to?(:template_method) # =...
...> true
# GNU/Linux で実行。C言語による実装部のため false を返す
puts File.respond_to?(:lchmod) # => false
//}

@see Module#method_defined?...

RubyVM::InstructionSequence#label -> String (37.0)

self が表す命令シーケンスのラベルを返します。通常、メソッド名、クラス名、 モジュール名などで構成されます。

...ラベルを返します。通常、メソッド名、クラス名、
モジュール名などで構成されます。

トップレベルでは "<main>" を返します。self を文字列から作成していた場合
は "<compiled>" を返します。

例1:irb で実行した場合

iseq = Ru...
...

# /tmp/method.rb
def hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello, world"
end

RubyVM::InstructionSequence.of(method(:hello)).label...

RubyVM::InstructionSequence#base_label -> String (31.0)

self が表す命令シーケンスの基本ラベルを返します。

...# /tmp/method.rb
def hello
puts "hello, world"
end

# irb
> iseq = RubyVM::InstructionSequence.compile_file('/tmp/method.rb')
> iseq.base_label # => "<main>"

例3:

# /tmp/method2.rb
def hello
puts "hello, world"
end

RubyVM::InstructionSequence.of(method(:hello)).base...

NameError#to_s -> String (25.0)

例外オブジェクトを文字列に変換して返します。

...オブジェクトを文字列に変換して返します。

例:

begin
foobar
rescue NameError => err
p err # => #<NameError: undefined local variable or method `foobar' for main:Object>
p err.to_s # => "undefined local variable or method `foobar' for main:Object"
end...

絞り込み条件を変える

IRB::ExtendCommand::Help#execute(*names) -> nil (19.0)

RI から Ruby のドキュメントを参照します。

...RI から Ruby のドキュメントを参照します。

irb(main):001:0> help String#match
...

@param names 参照したいクラス名やメソッド名などを文字列で指定します。

names を指定しなかった場合は、RI を対話的なモードで起動します。メソ...
...完をする
事ができます。また、空行を入力する事で irb のプロンプトに戻る事ができま
す。

irb(main):001:0> help

Enter the method name you want to look up.
You can use tab to autocomplete.
Enter a blank line to exit.

>> String#match
String#match

(f...

RubyVM::InstructionSequence#to_a -> Array (19.0)

self の情報を 14 要素の配列にして返します。

...bel

メソッド名、クラス名、モジュール名などで構成される命令シーケンスのラ
ベル。トップレベルでは "<main>"。文字列から作成していた場合は
"<compiled>"。

: #path

命令シーケンスの相対パス。文字列から作成してい...
...first_lineno

命令シーケンスの 1 行目の行番号。

: type

命令シーケンスの種別。
:top、:method、:block、:class、:rescue、:ensure、:eval、:main
:defined_guard のいずれか。

: locals

全ての引数名、ローカル変数名からなる Symbol の...

NameError#name -> Symbol (13.0)

この例外オブジェクトを発生させる原因となった 変数や定数、メソッドの名前をシンボルで返します。

...クトを発生させる原因となった
変数や定数、メソッドの名前をシンボルで返します。

例:

begin
foobar
rescue NameError => err
p err # => #<NameError: undefined local variable or method `foobar' for main:Object>
p err.name # => :foobar
end...