るりまサーチ

最速Rubyリファレンスマニュアル検索!
180件ヒット [1-100件を表示] (0.060秒)
トップページ > クエリ:Class#new[x] > クエリ:extend[x] > 種類:ライブラリ[x]

別のキーワード

  1. << rexml::attribute#name
  2. add rexml::attribute#name
  3. handle_interrupt thread#raise
  4. oid= openssl::x509::extension#oid
  5. oid openssl::x509::extension#oid=

検索結果

<< 1 2 > >>

cgi (139.0)

CGI プログラムの支援ライブラリです。

...) Version 1.1
* https://www.w3.org/CGI/

=== 使用例

==== フォームフィールドの値を得る

//emlist[][ruby]{
require "cgi"
cgi = CGI.new
values = cgi['field_name'] # <== 'field_name' の配列
# 'field_name' が指定されていなかったら、 ""を返す。
fields = cgi.keys...
...gi = CGI.new
params = cgi.params
//}

また CGI#params は毎回同じ Hash オブジェクトを返すので
以下のような使いかたもできます。

//emlist[][ruby]{
cgi.params['new_field_name'] = ["value"] # 新しいパラメータを加える
cgi.params['field_name'] = ["new_value"]...
...e を使うのが最も簡単です。

//emlist[][ruby]{
# 保存
require 'pstore'
db = PStore.new("query.db")
db.transaction do
db["params"] = cgi.params
end

# 復帰
require 'pstore'
db = PStore.new("query.db")
db.transaction do
cgi.params = db["params"]
end
//}

ただし、PStore は Ruby...

webrick/cgi (97.0)

一般の CGI 環境で webrick ライブラリのサーブレットと同じように CGI スクリプトを書くための ライブラリです。サーバが WEBrick でなくても使うことが出来ます。

...行されます。

例:

#!/usr/local/bin/ruby
require 'webrick/cgi'

class
MyCGI < WEBrick::CGI
def do_GET(req, res)
res["content-type"] = "text/plain"
ret = "hoge\n"
res.body = ret
end
end

MyCGI.new.start()

==== do_XXX メソッド

do_XXX メソッドの XXX には G...
...
収納されています。

require "webrick/cgi"
class
MyCGI < WEBrick::CGI
def do_GET(req, res)
req.query #=> Hash を返します。
req.query['q']
req.query['num']
end
end
MyCGI.new.start()

同じ名前のフィールドが複数あ...
...h_data メソッドを使います。

require "webrick/cgi"
class
MyCGI < WEBrick::CGI
def do_GET(req, res)
req.query['q'].list #=> フォームの値を保持した文字列の配列を返します。
end
end
MyCGI.new.start()

query メソッドが返す Hash オブジェクト...

cgi/session (67.0)

CGI のセッション管理を行うライブラリ。

...に、
ブラウザを終了した時点で消滅します。

=== 使い方 (生成)

require 'cgi/session'
cgi = CGI.new
session = CGI::Session.new(cgi)

CGI::Session.new に CGI オブジェクトを渡します。クライアントから渡された
セッション ID はクッキーかク...
...りました。

=== CGI::HtmlExtension#form の出力

CGI::Session.new 後の CGI::HtmlExtension#form は、セッション ID を
埋め込んだ隠しフィールドを自動出力するようになります。
CGI::Session.new は、これによって生成されたフォームフィールド...
...セッション維持に利用できます。

#!/usr/bin/ruby
require 'cgi'
require 'cgi/session'

cgi = CGI.new('html3')
File.umask(0077)
session = CGI::Session.new(cgi)
cgi.out('charset'=>'euc-jp') {
html = cgi.html {
cgi.head { cgi.title {'Form Demo'} }
cgi.body {...

drb/gw (55.0)

drb 通信を中継するゲートウェイ(DRb::GW)と、 中継に必要なオブジェクト識別子変換クラス(DRb::GWIdConv)、 および DRb::DRbObject への拡張が含まれています。

...//www2a.biglobe.ne.jp/~seki/ruby/drbssh.html

=== Example
この例は drb/gw.rb に含まれているものです。

foo.rb
require 'drb/drb'

class
Foo
include DRbUndumped
def initialize(name, peer=nil)
@name = name
@peer = peer
end

def ping(obj)
puts "#...
..._id_conv(DRb::GWIdConv.new)

front = DRb::GW.new

s1 = DRb::DRbServer.new('drbunix:/tmp/gw_b_a', front)
s2 = DRb::DRbServer.new('drbunix:/tmp/gw_b_c', front)

s1.thread.join
s2.thread.join

gw_a.rb
require 'drb/unix'
require_relative 'foo'

obj = Foo.new('a')
DRb.start_serv...
...gw_a", obj)

robj = DRbObject.new_with_uri('drbunix:/tmp/gw_b_a')
robj[:a] = obj

DRb.thread.join

gw_c.rb
require 'drb/unix'
require_relative 'foo'

foo = Foo.new('c', nil)

DRb.start_service("drbunix:/tmp/gw_c", nil)

robj = DRbObject.new_with_uri("drbunix:/tmp/gw_b_c")...

drb/extservm (49.0)

DRb::ExtServManager を定義しているライブラリ。

...指定する
s = DRb::ExtServManager.new
DRb.start_service("druby://localhost:10234", s)

# drb のプロセスの終了を待つ
DRb.thread.join

service.rb:
require 'drb/drb'
require 'drb/extserv'

# サービスを表すクラス
class
Service
include DRb::DRbUndumped...
...指定した引数が渡される
front = Service.new(ARGV[0])

# 通信のため drb を起動する
# ポート番号に 0 を指定すると ephemeral port から適当なポート番号が
# 選ばれる
server = DRb::DRbServer.new("druby://localhost:0", front)

# ARGV の最後...
...
# これによってブローカープロセスにサービスの
# 窓口となる ExtServ オブジェクトを渡す
es = DRb::ExtServ.new(ARGV[1], ARGV[2], server)

# サーバスレッドの停止を待つ
DRb.thread.join
# サービスを DRb::ExtServ#stop_service で止め...

絞り込み条件を変える

rdoc (49.0)

RDoc は Ruby のドキュメント生成を行うためのライブラリです。rdoc という ドキュメント生成のためのコマンドも含んでいます。

...pattern にマッチするディレクトリおよびファイルを処理の対象から取り除きます。

: --extension new=old

ファイル名の末尾が .new であるものを、末尾が .old であるものとして取
り扱います。例えば '--extension cgi=rb' とすれば...
...source directory. Default is
the current directory.

: --page-dir dir

Directory where guides, your FAQ or other pages not associated with
a class live. Set this when you don't store such files at your
project root. NOTE: Do not use the same file name in the page dir
and the root of your...
...。これをオフにしたい場合は all 修飾
子を加えます。

//emlist{
module SM #:nodoc:
class
Input
end
end
module Markup #:nodoc: all
class
Output
end
end
//}

以上のコードでは、SM::Input のドキュメントのみが出力され...

rexml/parsers/streamparser (43.0)

ストリーム式の XML パーサ。

...ソッドをオーバーライドしたクラスのオブジェクトを
コールバックオブジェクトとして REXML::Parsers::StreamParser.new
に渡します。

REXML::Parsers::StreamParser#parse を呼び出すと
パースが開始しその結果によってコールバックが呼び...
...意してください。

//emlist[][ruby]{
require 'rexml/parsers/baseparser'
require 'rexml/parsers/streamparser'
require 'rexml/streamlistener'
class
Listener
include REXML::StreamListener
def initialize
@events = []
end

def text(text)
@events << "text[#{text}]"
end

def tag_...
...="red">
<comment>comment here</comment>
</member>
<member name="banana" color="yellow"/>
</members>
EOS
listener = Listener.new
REXML::Parsers::StreamParser.new(xml, listener).parse
listener.events
# => ["tag_start[members]",
# "text[\n ]",
# "tag_start[member]",
# "text[\n ]...

yaml (43.0)

構造化されたデータを表現するフォーマットであるYAML (YAML Ain't Markup Language) を扱うためのライブラリです。

...35,
"birthday" => Date.new(1970, 1, 1)
}
str_r["Suzuki Suneo"] = {
"age" => 13,
"birthday" => Date.new(1992, 12, 21)
}

p str_r == YAML.load(str_l) # => true
//}

//emlist[例3: 構造化されたログ][ruby]{
require 'yaml'
require 'stringio'

strio_r = StringIO.new(<<~YAML_EOT)
---
tim...
...EOS
# => :foo
//}

yaml では、Ruby 向けに以下のローカルタグを扱えます。

* !ruby/array: Array オブジェクト
* !ruby/class: Class オブジェクト
* !ruby/hash: Hash オブジェクト
* !ruby/module: Module オブジェクト
* !ruby/regexp: Regexp オブジェク...
...mlist[例1][ruby]{
require 'yaml'

class
Foo
def initialize
@bar = "test"
end
end

p YAML.load(<<~EOS)
---
!ruby/object:Foo
bar: "test.modified"
EOS
# => #<Foo:0xf743f754 @bar="test.modified">
//}

//emlist[例2][ruby]{
require 'yaml'

module Foo
class
Bar
end
end

p YAML.load(<<~E...

drb (31.0)

分散オブジェクトプログラミングのためのライブラリです。

...を実行できて
しまいます。例えば以下のようなことができます。

# !! 危険 !!
ro = DRbObject.new_with_uri("druby://your.server.com:8989")
class
<< ro
# リモートオブジェクトの instance_eval を呼ぶため
# ローカルオブジェクトの instanc...
...ち受ける URI
SERVER_URI="druby://localhost:8787"

class
TimeServer

def get_current_time
return Time.now
end

end

# サーバ側でリクエストを受け付けるオブジェクト
FRONT_OBJECT=TimeServer.new

# サーバを起動する
DRb.start_service(...
...ブジェクト以外の
# リモートオブジェクトのメソッドを呼び出す時には必要
DRb.start_service
# リモートオブジェクトの取得
timeserver = DRbObject.new_with_uri(SERVER_URI)
# リモートメソッドの呼び出し
puts timeserver.get_current_time...

e2mmap (31.0)

例外クラスに特定のエラーメッセージ用フォーマットを関連づけるためのライブラリです。

...eMapper を extend すれば、
def_e2message メソッドや def_exception メソッドが使えます。
これらで例外クラスとメッセージを関連づけることができます。

例:

class
Foo
extend
Exception2MessageMapper
def_e2message ExistingExceptionClass, "message....
...f_exception :NewExceptionClass, "message...", StandardError
...
end

foo = Foo.new
foo.Fail ....

2. 何度も使いたい例外クラスは、クラスの代わりにモジュールで定義して、
それを include して使います。

例:

module ErrorMod
extend
Exception2M...
...essageMapper
def_e2message ExistingExceptionClass, "message..."
def_exception :NewExceptionClass, "message...", StandardError
...
end
class
Foo
include ErrorMod
...
end

foo = Foo.new
foo.Fail ....

3. 例外を設定したクラスのインスタンス以外から例...

絞り込み条件を変える

<< 1 2 > >>