るりまサーチ

最速Rubyリファレンスマニュアル検索!
302件ヒット [201-300件を表示] (0.066秒)
トップページ > クエリ:Ruby[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クエリ:self[x] > クラス:Object[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 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 being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumer...
...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#size...

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

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

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

ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 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 being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumer...
...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#size...

Object#display(out = $stdout) -> nil (50.0)

オブジェクトを out に出力します。

...mlist[][ruby]{
class Object
def display(out = $stdout)
out.write self
nil
end
end
//}

@
param out 出力先のIOオブジェクトです。指定しない場合は標準出力に出力されます。
@
return nil を返します。

//emlist[][ruby]{
Object
.new.display #=> #<Object:0xbb02...

Object#equal?(other) -> bool (42.0)

other が self 自身の時、真を返します。

...other が self 自身の時、真を返します。

二つのオブジェクトが同一のものかどうか調べる時に使用します。
このメソッドを再定義してはいけません。

お互いのObject#object_idが一致する
かどうかを調べます。

@
param other 比較...
...するオブジェクトです。

//emlist[][ruby]{
p("foo".equal?("bar")) #=> false
p("foo".equal?("foo")) #=> false

p(4.equal?(4)) #=> true
p(4.equal?(4.0)) #=> false

p(:foo.equal? :foo) #=> true
//}

@
see Object#object_id,Object#==,Object#eql?,Symbol...

Object#class -> Class (38.0)

レシーバのクラスを返します。

...レシーバのクラスを返します。

//emlist[][ruby]{
p "ruby".class #=> String
p 100.class #=> Integer
p ARGV.class #=> Array
p self.class #=> Object
p Class.class #=> Class
p Kernel.class #=> Module
//}

@
see Class#superclass,Object#kind_of?,Object#instance_of?...

絞り込み条件を変える

Object#marshal_load(obj) -> object (38.0)

Marshal.#load を制御するメソッドです。

... self は、生成されたばかり(Class#allocate されたばかり) の状態です。

marshal_dump/marshal_load の仕組みは Ruby 1.8.0 から導入されました。
これから書くプログラムでは _dump/_load ではなく
marshal_dump/marshal_load を使うべきです。

@
pa...
...ram obj marshal_dump の返り値のコピーです。

@
return 返り値は無視されます。


@
see Object#marshal_dump, Marshal...

Object#<=>(other) -> 0 | nil (36.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...
self
=== other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@
see Object#===...

Object#pretty_print(pp) -> () (32.0)

PP.pp や Kernel.#pp がオブジェクトの内容を出力するときに 呼ばれるメソッドです。PP オブジェクト pp を引数として呼ばれます。

...を定義しています。

@
param pp PP オブジェクトです。

//emlist[][ruby]{
require 'pp'

class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}

@
see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text,...
...ッドを定義しています。

@
param pp PP オブジェクトです。

//emlist[][ruby]{
class Array
def pretty_print(q)
q.group(1, '[', ']') {
q.seplist(self) {|v|
q.pp v
}
}
end
end
//}

@
see Object#pretty_print_cycle, Object#inspect, PrettyPrint#text, PrettyP...

Object#!~(other) -> bool (26.0)

自身が other とマッチしない事を判定します。

...自身が other とマッチしない事を判定します。

self
#=~(obj) を反転した結果と同じ結果を返します。

@
param other 判定するオブジェクトを指定します。

//emlist[例][ruby]{
obj = 'regexp'
p (obj !~ /re/) # => false

obj = nil
p (obj !~ /re/) # => true
/...
<< < 1 2 3 4 > >>