るりまサーチ

最速Rubyリファレンスマニュアル検索!
960件ヒット [701-800件を表示] (0.145秒)

別のキーワード

  1. openssl t61string
  2. asn1 t61string
  3. matrix t
  4. t61string new
  5. fiddle type_size_t

検索結果

<< < ... 6 7 8 9 10 > >>

Module#remove_method(*name) -> self (6102.0)

インスタンスメソッド name をモジュールから削除します。

...String か Symbol を指定します。

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

//emlist[例][ruby]{
class C
def foo
end

remove_method :foo
remove_method :no_such_method # 例外 NameError が発生
end
//}

@see Module#undef_meth...

Module#singleton_class? -> bool (6102.0)

self が特異クラスの場合に true を返します。そうでなければ false を返し ます。

...self が特異クラスの場合に true を返します。そうでなければ false を返し
ます。

//emlist[例][ruby]{
class C
end
C.singleton_class? # => false
C.singleton_class.singleton_class? # => true
//}...

Module#to_s -> String (6102.0)

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

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

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

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

p B.name #=> "A::B"...
...lass 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#undef_method(*name) -> self (6102.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....
...ve_method の場合はスーパークラスに同名のメソッドがあると
# それが呼ばれる
class B
remove_method :ok
end
B.new.ok # => A
//}

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

//emlist[例...

Module#name -> String | nil (3102.0)

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

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

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

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

p B.name #=> "A::B"...
...lass 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#class_exec(*args) {|*vars| ... } -> object (120.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...す。


//emlist[例][ruby]{
class Thing
end
c = 1

T
hing.class_exec{
def hello()
"Hello there!"
end

define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t
= Thing.new
p t.hello() #=> "Hello there!"
p t.foo()...
...#=> 1
//}

@see Module#module_eval, Module#class_eval...

Module#module_exec(*args) {|*vars| ... } -> object (120.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...す。


//emlist[例][ruby]{
class Thing
end
c = 1

T
hing.class_exec{
def hello()
"Hello there!"
end

define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t
= Thing.new
p t.hello() #=> "Hello there!"
p t.foo()...
...#=> 1
//}

@see Module#module_eval, Module#class_eval...

Module#<(other) -> bool | nil (102.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...較演算子。self が other の子孫である場合、 true を返します。
self が other の先祖か同一のクラス/モジュールである場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモジ...
...やクラス

@raise TypeError other がクラスやモジュールではない場合に発生します。

//emlist[例][ruby]{
module
Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar < Foo # => true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux...
...# => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}...

Module#<=(other) -> bool | nil (102.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...算子。self が other の子孫であるか、self と other が
同一クラスである場合、 true を返します。
self が other の先祖である場合、false を返します。

継承関係にないクラス同士の比較では
nil を返します。

@param other 比較対象のモ...
...@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module
Foo; end
module
Bar
include Foo
end
module
Baz
prepend Foo
end

Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

Baz.ancestors # =>...
...[Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true

Foo <= Foo # => true
Foo <= Object # => nil
//}...
<< < ... 6 7 8 9 10 > >>