246件ヒット
[101-200件を表示]
(0.033秒)
別のキーワード
種類
- インスタンスメソッド (156)
- モジュール関数 (42)
- ライブラリ (24)
- 定数 (12)
- 特異メソッド (12)
ライブラリ
- ビルトイン (192)
-
bigdecimal
/ math (12) - cmath (6)
-
rdoc
/ parser / ruby (12)
クラス
- BasicObject (48)
- Module (36)
- Object (72)
-
RDoc
:: Parser :: Ruby (12)
オブジェクト
- main (12)
キーワード
- SINGLE (12)
- asin (12)
- bigdecimal (12)
-
bigdecimal
/ math (12) -
const
_ missing (12) -
define
_ singleton _ method (24) -
method
_ missing (12) -
respond
_ to _ missing? (12) - sin! (6)
-
singleton
_ class (12) -
singleton
_ class? (12) -
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) - using (24)
検索結果
先頭5件
-
main
. using(module) -> self (6112.0) -
引数で指定したモジュールで定義された拡張を有効にします。
...* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
//emlist[例][ruby]{
module Sloth
refine String do
def downcase
self
end
end
end
"ABC".downcase # => "abc"
using Sloth
"ABC".dow......ncase # => "ABC"
//}
@see Module#refine, Module#using... -
BasicObject
# singleton _ method _ added(name) -> object (6106.0) -
特異メソッドが追加された時にインタプリタから呼び出されます。
...。
//emlist[例][ruby]{
class Foo
def singleton_method_added(name)
puts "singleton method \"#{name}\" was added"
end
end
obj = Foo.new
def obj.foo
end
#=> singleton method "foo" was added
//}
@see Module#method_added,BasicObject#singleton_method_removed,BasicObject#singleton_method_unde... -
BasicObject
# singleton _ method _ removed(name) -> object (6106.0) -
特異メソッドが Module#remove_method に より削除された時にインタプリタから呼び出されます。
...//emlist[例][ruby]{
class Foo
def singleton_method_removed(name)
puts "singleton method \"#{name}\" was removed"
end
end
obj = Foo.new
def obj.foo
end
class << obj
remove_method :foo
end
#=> singleton method "foo" was removed
//}
@see Module#method_removed,BasicObject#singleton_method......_added,BasicObject#singleton_method_undefined... -
BasicObject
# singleton _ method _ undefined(name) -> object (6106.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...st[例][ruby]{
class Foo
def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end
obj = Foo.new
def obj.foo
end
def obj.bar
end
class << obj
undef_method :foo
end
obj.instance_eval {undef bar}
#=> singleton method "foo" was undefined
# singleton m......ethod "bar" was undefined
//}
@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef... -
Module
# singleton _ class? -> bool (6106.0) -
self が特異クラスの場合に true を返します。そうでなければ false を返し ます。
...self が特異クラスの場合に true を返します。そうでなければ false を返し
ます。
//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}... -
Module
# using(module) -> self (6106.0) -
引数で指定したモジュールで定義された拡張を現在のクラス、モジュールで有 効にします。
...ルで有
効にします。
有効にした拡張の有効範囲については以下を参照してください。
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
@see Module#refine, main.using... -
Object
# define _ singleton _ method(symbol) { . . . } -> Symbol (6106.0) -
self に特異メソッド name を定義します。
...を表す Symbol を返します。
//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }... -
Object
# define _ singleton _ method(symbol , method) -> Symbol (6106.0) -
self に特異メソッド name を定義します。
...を表す Symbol を返します。
//emlist[][ruby]{
class A
class << self
def class_name
to_s
end
end
end
A.define_singleton_method(:who_am_i) do
"I am: #{class_name}"
end
A.who_am_i # ==> "I am: A"
guy = "Bob"
guy.define_singleton_method(:hello) { "#{self}: Hello there!" }... -
Object
# respond _ to _ missing?(symbol , include _ private) -> bool (6106.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...ドに対し
BasicObject#method_missing で反応するつもりならば真を返します。
Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。
BasicObject#method_missing を override した場合にこの......true が渡されます
//emlist[例][ruby]{
class Sample
def method_missing(name, *args)
if name =~ /^to_*/
[name, *args] # => [:to_sample, "sample args1", "sample args2"]
return
else
super
end
end
def respond_to_missing?(sym, include_private)
(sym =~ /^to......_*/) ? true : super
end
end
s = Sample.new
s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}
@see Object#respond_to?, BasicObject#method_missing... -
Object
# singleton _ class -> Class (6106.0) -
レシーバの特異クラスを返します。 まだ特異クラスがなければ、新しく作成します。
...します。
@raise TypeError レシーバが Integer、Float、Symbol の場合に発生します。
//emlist[][ruby]{
Object.new.singleton_class #=> #<Class:#<Object:0xb7ce1e24>>
String.singleton_class #=> #<Class:String>
nil.singleton_class #=> NilClass
//}
@see Object#class...