るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.030秒)
トップページ > バージョン:2.5.0[x] > クエリ:proc[x] > クエリ:new[x] > 種類:クラス[x]

別のキーワード

  1. _builtin to_proc
  2. _builtin proc
  3. proc curry
  4. httpserver mount_proc
  5. readline completion_proc

キーワード

検索結果

Proc (18922.0)

ブロックをコンテキスト(ローカル変数のスコープやスタックフ レーム)とともにオブジェクト化した手続きオブジェクトです。

ブロックをコンテキスト(ローカル変数のスコープやスタックフ
レーム)とともにオブジェクト化した手続きオブジェクトです。

Proc は ローカル変数のスコープを導入しないことを除いて
名前のない関数のように使えます。ダイナミックローカル変数は
Proc ローカルの変数として使えます。

Proc がローカル変数のスコープを保持していることは以下の例で
変数 var を参照できていることからわかります。

//emlist[例][ruby]{
var = 1
$foo = Proc.new { var }
var = 2

def foo
$foo.call
end

p foo ...

Method (292.0)

Object#method によりオブジェクト化され たメソッドオブジェクトのクラスです。

...、Method は大規模コードに向くと言えます。


既存のメソッドを Method オブジェクト化する。

//emlist[例][ruby]{
class
Foo
def foo(arg)
"foo called with arg #{arg}"
end
end

m = Foo.new.method(:foo)

p m # => #<Method: Foo#foo>
p m.call(1) # =...
...cc>
p pr.call(1) # => "proc called with arg 1"
//}

Method オブジェクトが有用なのは以下のような場合。

//emlist[例][ruby]{
class
Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

obj = Foo.new

# 任意のキーとメソッドの関係をハッシュ...
...(Method オブジェクトはレシーバを保持する)必
要がないなら Object#public_sendを使う方法も有用。

//emlist[例][ruby]{
class
Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end

# 任意のキーとメソッド(の名前)の関係をハッシュに...

WEBrick::HTTPAuth::BasicAuth (76.0)

HTTP の Basic 認証のためのクラスです。

HTTP の Basic 認証のためのクラスです。



require 'webrick'
realm = "WEBrick's realm"
srv = WEBrick::HTTPServer.new({ :BindAddress => '127.0.0.1', :Port => 10080})

htpd = WEBrick::HTTPAuth::Htpasswd.new('dot.htpasswd')
htpd.set_passwd(nil, 'username', 'supersecretpass')

authenticator =...