るりまサーチ

最速Rubyリファレンスマニュアル検索!
1341件ヒット [101-200件を表示] (0.029秒)

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

ライブラリ

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Class.new(superclass = Object) {|klass| ... } -> Class (18229.0)

新しく名前の付いていない superclass のサブクラスを生成します。

...める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。

//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name # => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name...
...s.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}

この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。

@param superclass 生成するクラスのスーパークラスを指定します。

//emlist[例][ruby]{
k = Class.new{...
...|c|
def initialize
p "in initialize"
end

def hoge
p "hoge hoge hoge"
end
}
o = k.new #=> "in initialize"
o.hoge #=> "hoge hoge hoge"
//}...

OpenSSL::X509::Name.new(ary, template = OBJECT_TYPE_TEMPLATE) -> OpenSSL::X509::Name (18217.0)

OpenSSL::X509::Name オブジェクトを生成します。

...:
require 'openssl'
OpenSSL::X509::Name.new([["C", "JP"], ["ST", "Kanagawa"], ["L", "Yokohama"], ["O", "Example Company"], ["OU", "Lab3"], ["CN", "foobar"], ["emailAddress", "foobar@lab3.example.co.jp"]])
# => OpenSSL::X509::Name object: /C=JP/ST=Kanagawa/L=Yokohama/O=Example Company/OU=...

UNIXServer.new(path) {|sock| ...} -> object (18211.0)

path で指定したパス名を用いて接続を受け付けるソケット を作成します。

...クを呼びだし、
ブロック終了時にソケットを閉じます。この場合には
ブロックの評価値を返り値として返します。

@param path 接続を受け付けるパス名文字列

require 'socket'

serv = UNIXServer.new("/tmp/sock")
s = serv.accept
p s.read...

UNIXSocket.new(path) {|sock| ...} -> object (18211.0)

path で指定したパス名を用いてソケットを接続します。

...してそのブロックを呼びだし、
ブロック終了時にソケットを閉じます。この場合には
ブロックの評価値を返り値として返します。

@param path 接続先のパス名文字列

require 'socket'

s = UNIXSocket.new("/tmp/sock")
s.send("hello", 0)...

SimpleDelegator.new(obj) -> object (18209.0)

メソッドを委譲するオブジェクトの設定と、 メソッド委譲を行うためのクラスメソッドの定義を行います。

...メソッドを委譲するオブジェクトの設定と、
メソッド委譲を行うためのクラスメソッドの定義を行います。

@param obj 委譲先のオブジェクト

@see Delegator.new...

絞り込み条件を変える

WIN32OLE_TYPELIB.new(libname, mjv = nil, miv = nil) -> WIN32OLE_TYPELIB (18162.0)

WIN32OLE_TYPELIBオブジェクトを生成します。

...

tlib1 = WIN32OLE_TYPELIB.new('Microsoft Excel 14.0 Object Library')
tlib2 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}')
tlib3 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1.7)
tlib4 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000...
...PELIB.new("C:\\WINDOWS\\SYSTEM32\\SHELL32.DLL")
puts tlib1.name # => 'Microsoft Excel 14.0 Object Library'
puts tlib2.name # => 'Microsoft Excel 14.0 Object Library'
puts tlib3.name # => 'Microsoft Excel 14.0 Object Library'
puts tlib4.name # => 'Microsoft Excel 14.0 Object Libra...

Hash.new {|hash, key| ... } -> Hash (18151.0)

空の新しいハッシュを生成します。ブロックの評価結果がデフォルト値になりま す。設定したデフォルト値はHash#default_procで参照できます。

...応する値も変更されます。
h = Hash.new("foo")

p h[1] #=> "foo"
p h[1].object_id #=> 6127170
p h[1] << "bar" #=> "foobar"
p h[1] #=> "foobar"

p h[2] #=> "foobar"
p h[2].object_id #=> 6127170

p h...
...クトになります。
h = Hash.new {|hash, key| hash[key] = "foo"}

p h[1] #=> "foo"
p h[1].object_id #=> 6126900
p h[1] << "bar" #=> "foobar"
p h[1] #=> "foobar"

p h[2] #=> "foo"
p h[2].object_id #=> 6126840

p h...
...#=> {1=>"foobar", 2=>"foo"}

# 値が設定されていないときに(fetchのように)例外をあげるようにもできる
h = Hash.new {|hash, key|
raise(IndexError, "hash[#{key}] has no value")
}
h[1]
# エラー hash[1] has no value (IndexError)
//}...

Hash.new(ifnone = nil) -> Hash (18146.0)

空の新しいハッシュを生成します。ifnone はキーに対 応する値が存在しない時のデフォルト値です。設定したデフォルト値はHash#defaultで参照できます。

...省略した Hash.new は {} と同じです。

デフォルト値として、毎回同一のオブジェクトifnoneを返します。
それにより、一箇所のデフォルト値の変更が他の値のデフォルト値にも影響します。

//emlist[][ruby]{
h = Hash.new([])
h[0] << 0
h[...
...[ruby]{
h = Hash.new([])

p h[1] #=> []
p h[1].object_id #=> 6127150
p h[1] << "bar" #=> ["bar"]
p h[1] #=> ["bar"]

p h[2] #=> ["bar"]
p h[2].object_id #=> 6127150

p h #=> {}


h = Hash.new([].freeze)
h[0]...

Proc.new -> Proc (18145.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメ...
...ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#...
...umentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクト...

Proc.new { ... } -> Proc (18145.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しなければ、このメ...
...ブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p arg }
#...
...umentError が発生します。

//emlist[例][ruby]{
def foo
Proc.new
end
foo
# => -:2:in `new': tried to create Proc object without a block (ArgumentError)
# from -:2:in `foo'
# from -:4:in `<main>'
//}

Proc.new は、Proc#initialize が定義されていれば
オブジェクト...

絞り込み条件を変える

<< < 1 2 3 4 ... > >>