るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. fiddle build_ruby_platform
  3. rbconfig ruby
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

検索結果

<< 1 2 > >>

Object#methods(include_inherited = true) -> [Symbol] (27422.0)

そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。

...メソッドは public メソッドおよび protected メソッドの名前を返します。

ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。


@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じに...
...st[例1][ruby]{
class Parent
private; def private_parent() end
protected; def protected_parent() end
public; def public_parent() end
end

class Foo < Parent
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end

obj = Foo.n...
...s <<obj
private; def private_singleton() end
protected; def protected_singleton() end
public; def public_singleton() end
end

# あるオブジェクトの応答できるメソッドの一覧を得る。
p obj.methods(false)
p obj.public_methods(false)
p obj.private_methods(fal...

Module#ruby2_keywords(method_name, ...) -> nil (18644.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...For the given method names, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword argument...
...other method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. In other words, keywords will be passed through the method to
other methods.

This should only be used for methods that delegate keywords to another
method
, an...
...d only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
b
efore 2.7, check that the module responds to this method before calling
it. Also, be aware that...

Proc#ruby2_keywords -> proc (18435.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
b
ut not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
...nother method call, and that
method
call does not include explicit keywords or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
b
e passed through the proc to other methods.

This should only be used for procs that delegate keywords to another
method
, and...
...only for backwards compatibility with Ruby versions before
2.7.

This method will probably be removed at some point, as it exists only
for backwards compatibility. As it does not exist in Ruby versions
b
efore 2.7, check that the proc responds to this method before calling
it. Also, be aware that if...

Object#singleton_methods(inherited_too = true) -> [Symbol] (15380.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...対して定義されている特異メソッド名
(public あるいは protected メソッド) の一覧を返します。

inherited_too が真のときは継承した特異メソッドを含みます。
継承した特異メソッドとは Object#extend によって追加された特異メソッ...
...ド)などです。

singleton_methods(false) は、Object#methods(false) と同じです。

@param inherited_too 継承した特異メソッドを含める場合は真を、
そうでない場合は偽を指定します。

//emlist[例1][ruby]{
Parent = Class.new

class <<Par...
...blic; def public_class_parent() end
end

Foo = Class.new(Parent)

class <<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end
public; def public_class_foo() end
end

module Bar
private; def private_bar() end
protected; def protected_bar() end
pub...

Module#instance_methods(inherited_too = true) -> [Symbol] (12404.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

...で定義されている public および protected メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#methods

//emlist[例1][ruby]{
class Foo
private; def...
...ected_foo() end
public; def public_foo() end
end

# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(false)
p Foo.protected_instance_methods(false)

class Bar < Foo
end
//}...
...実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]

//emlist[例2][ruby]{
class Bar
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end

# あるクラスのインスタンスメ...

絞り込み条件を変える

Module#private_instance_methods(inherited_too = true) -> [Symbol] (12338.0)

そのモジュールで定義されている private メソッド名 の一覧を配列で返します。

...ます。

@see Object#private_methods, Module#instance_methods

//emlist[例][ruby]{
module Foo
def foo; end
private def bar; end
end

module Bar
include Foo

def baz; end
private def qux; end
end

B
ar.private_instance_methods # => [:qux, :bar]
B
ar.private_instance_methods(false) # => [:q...

JSON::Generator::GeneratorMethods::Object#to_json(state_or_hash = nil) -> String (9019.0)

自身を to_s で文字列にした結果を JSON 形式の文字列に変換して返します。

...例][ruby]{
require "json"

class Person
attr :name, :age

def initialize(name, age)
@name, @age = name, age
end
end

tanaka = Person.new("tanaka", 29)

tanaka.to_json # => "\"#<Person:0x00007ffdec0167c8>\""
tanaka.method(:to_json).owner # => JSON::Ext::Generator::GeneratorMethods::Object...

Module#undef_method(*name) -> self (6234.0)

このモジュールのインスタンスメソッド name を未定義にします。

...このモジュールのインスタンスメソッド name を未定義にします。

@param name 0 個以上の String か Symbol を指定します。

@raise NameError 指定したインスタンスメソッドが定義されていない場合に発生します。

=== 「未定義にする...
...//emlist[例][ruby]{
class A
def ok
puts 'A'
end
end
class B < A
def ok
puts 'B'
end
end

B
.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B
.new.ok # =...
...> NameError

# remove_method の場合はスーパークラスに同名のメソッドがあると
# それが呼ばれる
class B
remove_method :ok
end
B
.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることで...

Object#send(name, *args) -> object (3173.0)

オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。

...ublic メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。

@param name 文字列かSymbol で指定するメソッド名です。
@param args 呼び出すメソッドに渡す引数です。

//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby"...
...ub,/./,"R") #=> "Ruby"


class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに保持しておく
# レシーバの情報がここにはないことに注意
methods
= {1 => :foo,
2 => :bar,
3 => :ba...
...ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}

@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...
<< 1 2 > >>