るりまサーチ

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

別のキーワード

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

検索結果

<< 1 2 3 ... > >>

Module#name -> String | nil (18257.0)

モジュールやクラスの名前を文字列で返します。

...しては「CGI::Session」「Net::HTTP」が挙げられます。

@return 名前のないモジュール / クラスに対しては、name は nil を、それ以外はオブジェクト ID の文字列を返します。

//emlist[例][ruby]{
module
A
module
B
end

p B.name #=> "A::B"

cl...
...ass C
end
end

p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"

# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}...

Module#ruby2_keywords(method_name, ...) -> nil (12465.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.

...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 fi...
...al 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 thr...
...ethods.

This should only be used for methods 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
before...

Module#const_defined?(name, inherit = true) -> bool (6337.0)

モジュールに name で指定される名前の定数が定義されている時真 を返します。

...ュールに name で指定される名前の定数が定義されている時真
を返します。

スーパークラスや include したモジュールで定義された定数を検索対象
にするかどうかは第二引数で制御することができます。

@param name String, Symbol...
...で指定される定数名。

@param inherit false を指定するとスーパークラスや include したモジュールで
定義された定数は対象にはなりません。

//emlist[例][ruby]{
module
Kernel
FOO = 1
end

# Object は include したモジュールの定数に対...
...しても
# true を返す
p Object.const_defined?(:FOO) # => true

module
Bar
BAR = 1
end
class Object
i
nclude Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defined?(:BAR) # => true

class Baz
i
nclude Bar
end
# Object 以外でも同様になった
# 第...

Module#method_defined?(name, inherit=true) -> bool (6337.0)

モジュールにインスタンスメソッド name が定義されており、 かつその可視性が public または protected であるときに true を返します。

...ンスタンスメソッド name が定義されており、
かつその可視性が public または protected であるときに
true を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュール...
...@see Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end
class B
def method2() end
def private_method2() end
private :private_me...
...B
i
nclude A
def method3() end
end

A.method_defined? :method1 #=> true
C.method_defined? "method1" #=> true
C.method_defined? "method2" #=> true
C.method_defined? "method2", true #=> true
C.method_defined? "method2", false #=> false
C.method_defin...

Module#protected_method_defined?(name, inherit=true) -> bool (6337.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

... name がモジュールに定義されており、
しかもその可視性が protected であるときに true を返します。
そうでなければ false を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや inc...
...になります。

@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
i
nclude A
def method3() end
end

A.method_defined? :method1...
...#=> true
C.protected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "method2", false #=> false
C.method_defined? "method2" #=> true
//}...

絞り込み条件を変える

Module#attr_writer(*name) -> [Symbol] (6289.0)

インスタンス変数 name への書き込みメソッド (name=) を定義します。

...インスタンス変数 name への書き込みメソッド (name=) を定義します。

//emlist[例][ruby]{
class User
attr_writer :name # => [:name=]
# 複数の名前を渡すこともできる
attr_writer :id, :age # => [:id=, :age=]
end
//}

このメソッドで定義されるメソ...
...ッドの定義は以下の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end
//}

@param name String または Symbol を 1 つ以上指定します。
@return 定義されたメソッド名を Symbol の配列で返します。...

Module#attr_writer(*name) -> nil (6265.0)

インスタンス変数 name への書き込みメソッド (name=) を定義します。

...インスタンス変数 name への書き込みメソッド (name=) を定義します。


このメソッドで定義されるメソッドの定義は以下の通りです。

//emlist[例][ruby]{
def name=(val)
@name = val
end
//}

@param name String または Symbol を 1 つ以上指定し...

Module#inspect -> String (6257.0)

モジュールやクラスの名前を文字列で返します。

...しては「CGI::Session」「Net::HTTP」が挙げられます。

@return 名前のないモジュール / クラスに対しては、name は nil を、それ以外はオブジェクト ID の文字列を返します。

//emlist[例][ruby]{
module
A
module
B
end

p B.name #=> "A::B"

cl...
...ass C
end
end

p A.name #=> "A"
p A::B.name #=> "A::B"
p A::C.name #=> "A::C"

# 名前のないモジュール / クラス
p Module.new.name #=> nil
p Class.new.name #=> nil
p Module.new.to_s #=> "#<Module:0x00007f90b09112c8>"
p Class.new.to_s #=> "#<Class:0x00007fa5c40b41b0>"
//}...

Module#const_missing(name) (6253.0)

定義されていない定数を参照したときに Ruby インタプリタが このメソッドを呼びます。

...きに Ruby インタプリタが
このメソッドを呼びます。

@param name 参照した定数名の Symbol

@raise NameError このメソッドを呼び出した場合、デフォルトで発生する例外


//emlist[例][ruby]{
class Foo
def Foo.const_missing(id)
warn "undefined con...
...stant #{id.inspect}"
end

Bar
end
Foo::Bar

# => undefined constant :Bar
# undefined constant :Bar
//}...

Module#method_undefined(name) -> () (6249.0)

このモジュールのインスタンスメソッド name が Module#undef_method によって削除されるか、 undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。

... name
Module
#undef_method によって削除されるか、
undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。

特異メソッドの削除をフックするには
BasicObject#singleton_method_undefined
を使います。

@param name...
...ド名が Symbol で渡されます。

//emlist[例][ruby]{
class C
def C.method_undefined(name)
puts "method C\##{name} was undefined"
end

def foo
end
def bar
end

undef_method :foo
undef bar
end
//}

実行結果:

method C#foo was undefined
method C#bar was undefined...

絞り込み条件を変える

<< 1 2 3 ... > >>