るりまサーチ

最速Rubyリファレンスマニュアル検索!
99件ヒット [1-99件を表示] (0.063秒)
トップページ > クエリ:p[x] > クエリ:<[x] > クラス:Object[x]

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dh p
  5. rsa p

ライブラリ

キーワード

検索結果

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

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

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

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


@param include_inherited 引数が偽の時は Object#singleton_methods(false)...
...s Parent
p
rivate; def private_parent() end
p
rotected; def protected_parent() end
p
ublic; def public_parent() end
end

class Foo < Parent
p
rivate; def private_foo() end
p
rotected; def protected_foo() end
p
ublic; def public_foo() end
end

obj = Foo.new
class <<obj
p
...
...e; def private_singleton() end
p
rotected; def protected_singleton() end
p
ublic; def public_singleton() end
end

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

Object#is_a?(mod) -> bool (43.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...も真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返します。

@param mod クラスやモジュールなど、Moduleかそ...
...です。

//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end

obj = S.new
p
obj.is_a?(S) # true
p
obj.is_a?(C) # true
p
obj.is_a?(Object) # true
p
obj.is_a?(M) # true
p
obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

Object#kind_of?(mod) -> bool (43.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...も真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返します。

@param mod クラスやモジュールなど、Moduleかそ...
...です。

//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end

obj = S.new
p
obj.is_a?(S) # true
p
obj.is_a?(C) # true
p
obj.is_a?(Object) # true
p
obj.is_a?(M) # true
p
obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

Object#instance_of?(klass) -> bool (25.0)

オブジェクトがクラス klass の直接のインスタンスである時真を返します。

...常に obj.kind_of?(c) も成立します。

@param klass Classかそのサブクラスのインスタンスです。

//emlist[][ruby]{
class C < Object
end
class S < C
end

obj = S.new
p
obj.instance_of?(S) # true
p
obj.instance_of?(C) # false
//}

@see Object#kind_of?,Object#class...

Object#enum_for(method = :each, *args) -> Enumerator (19.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p
(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from...
...dified
a = [1, 2, 3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

絞り込み条件を変える

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (19.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p
(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from...
...dified
a = [1, 2, 3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

Object#to_enum(method = :each, *args) -> Enumerator (19.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p
(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from...
...dified
a = [1, 2, 3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (19.0)

Enumerator.new(self, method, *args) を返します。

...数 args です。


@param method メソッド名の文字列かシンボルです。
@param args 呼び出すメソッドに渡される引数です。

//emlist[][ruby]{
str = "xyz"

enum = str.enum_for(:each_byte)
p
(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]

# protects an array from...
...dified
a = [1, 2, 3]
p
(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは :repeat
return to_...
...end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}

@see Enumerator, Enumerator#s...

Object#initialize(*args, &block) -> object (13.0)

ユーザ定義クラスのオブジェクト初期化メソッド。

...動的に private に設定され
ます。

@param args 初期化時の引数です。
@param block 初期化時のブロック引数です。必須ではありません。

//emlist[][ruby]{
class Foo
def initialize name
p
uts "initialize Foo"
@name = name
end
end

class Bar < Foo
def...
...initialize name, pass
p
uts "initialize Bar"
super name
@pass = pass
end
end

it = Bar.new('myname','0500')
p
it
#=> initialize Bar
# initialize Foo
# #<Bar:0x2b68f08 @name="myname", @pass="0500">
//}

@see Class#new...