ライブラリ
- ビルトイン (34)
-
cgi
/ core (33) -
cgi
/ html (22) -
cgi
/ util (11) -
net
/ http (55) -
net
/ imap (363) - openssl (11)
-
rdoc
/ markup (11) -
webrick
/ httprequest (22) -
webrick
/ httpresponse (44)
クラス
- CGI (33)
- Data (4)
-
Net
:: HTTPGenericRequest (11) -
Net
:: HTTPResponse (44) -
Net
:: IMAP :: BodyTypeBasic (99) -
Net
:: IMAP :: BodyTypeMessage (99) -
Net
:: IMAP :: BodyTypeMultipart (55) -
Net
:: IMAP :: BodyTypeText (99) -
Net
:: IMAP :: FetchData (11) -
RubyVM
:: InstructionSequence (22) -
WEBrick
:: HTTPRequest (22) -
WEBrick
:: HTTPResponse (44)
モジュール
-
CGI
:: HtmlExtension (22) -
CGI
:: QueryExtension (11) -
RubyVM
:: AbstractSyntaxTree (8)
キーワード
- Markup (11)
-
NEWS for Ruby 2
. 5 . 0 (7) - OCSP (11)
- attr (11)
- cgi (11)
-
content
_ id (33) -
content
_ length (11) -
content
_ length= (11) -
create
_ body (11) - define (4)
- description (33)
- disasm (11)
- disassemble (11)
- encoding (33)
- entity (11)
- header (11)
- html (22)
- language (44)
- md5 (33)
-
media
_ subtype (44) -
media
_ type (44) - param (44)
- parse (8)
- pretty (11)
- print (11)
-
read
_ body (22) -
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 3 feature (11) -
ruby 1
. 9 feature (11) - subtype (44)
-
to
_ s (11) -
webrick
/ cgi (11) - クラス/メソッドの定義 (11)
検索結果
先頭5件
-
Data
. define(*args) {|subclass| block } -> Class (42.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...用できます。
//emlist[例][ruby]{
class HTTPFetcher
Response = Data.define(:body)
NotFound = Data.define
def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
NotFound.new
end
end
end
def......fetch(url)
fetcher = HTTPFetcher.new
case fetcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end
p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}
@par......ブジェクトのクラスを定義するための可変長引数。Symbol または String を指定します。
@return Data のサブクラスを返します。
@raise TypeError 引数に Symbol, String (String に暗黙の型変換が行われるオブジェクトを含む) 以外を指定し... -
WEBrick
:: HTTPResponse # content _ length -> Integer | nil (36.0) -
Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
...す。
: body が String オブジェクトである場合
content_length の値が nil のとき Content-Length ヘッダには
body のサイズが使われます。nil でないとき body の実際のサイズとこの値が同じかどうかの検証は行われません。
: body が IO......は出来ません。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 12:04:32 GM... -
WEBrick
:: HTTPResponse # content _ length=(len) (36.0) -
Content-Length ヘッダの値を整数で表すアクセサです。デフォルトは nil です。
...す。
: body が String オブジェクトである場合
content_length の値が nil のとき Content-Length ヘッダには
body のサイズが使われます。nil でないとき body の実際のサイズとこの値が同じかどうかの検証は行われません。
: body が IO......は出来ません。
require 'webrick'
include WEBrick
res = HTTPResponse.new( { :HTTPVersion => "1.1" } )
f = File.new('testfile')
res.body = f
res.content_length = 2
print res.to_s
#=> 出力結果
HTTP/1.1 200 OK
Connection: Keep-Alive
Date: Sat, 27 Oct 2007 12:04:32 GM... -
webrick
/ cgi (30.0) -
一般の CGI 環境で webrick ライブラリのサーブレットと同じように CGI スクリプトを書くための ライブラリです。サーバが WEBrick でなくても使うことが出来ます。
...by
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 には GET, HEAD, POST, PUT, DELETE, OPTIONS が使用......が呼ばれた時点では、クライアントからのリクエストに含まれる Entity Body の読み込みは
まだ行われていません。WEBrick::HTTPRequest#query, WEBrick::HTTPRequest#body などの
メソッドが読ばれた時点で読み込みが行われます。クライアン......ブジェクトのキーと値のうち値は WEBrick::HTTPUtils::FormData クラスの
インスタンスになります。FormData クラスは String クラスのサブクラスです。
==== マルチパートフィールドの値を取得する(ファイル送信)
require "webrick/cgi"... -
クラス/メソッドの定義 (30.0)
-
クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined
...ray を明示的に指定しても同じ)
class Foo
def bar
end
end
# 間違ったスーパークラスを指定するとエラー
class Foo < String
end
# => superclass mismatch for class Foo (TypeError)
//}
クラス定義式の中は self がそのクラスであることと、
limitのデ......['(' [arg0 ['=' default0]] ... [',' '*' rest_args [, post ...]] [',' key1: [val1]] ... [',' '**'kwrest] [',' '&' block_arg]`)']
式.. (body)
[rescue [error_type,..] [=> evar] [then]
式..]..
[else
式..]
[ensure
式..]......呼び出されると、以下の順で式が評価されます。
* 指定されていれば引数のデフォルト式
* メソッドの本体 body
* 指定されていれば例外の発生の有無によりメソッド定義式の rescue
節または else 節
* 指定されていれば en... -
cgi (24.0)
-
CGI プログラムの支援ライブラリです。
.../emlist[][ruby]{
require "cgi"
cgi = CGI.new
value = cgi.params['field_name'][0] # TempFile オブジェクト(10240バイト未満の場合は StringIOオブジェクト)
value.read # 本文(送られてきたファイルの中身)
value.local_path......= Time.now + 30
end
cgi.out("cookie" => cgi.cookies){"string"}
cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
require "cgi"
cgi = CGI.new
cgi.cookies['name'].expires = Time.now + 30
cgi.out("cookie" => cgi.cookies['name']){"string"}
//}
==== クライアントからクッキーを......{
require "cgi"
cgi = CGI.new("html3") # HTML生成メソッドを追加
cgi.out() do
cgi.html() do
cgi.head{ cgi.title{"TITLE"} } +
cgi.body() do
cgi.form() do
cgi.textarea("get_text") +
cgi.br +
cgi.submit
end +
cgi.pre() do
CGI.escapeHT... -
RDoc
:: Markup (18.0) -
RDoc 形式のドキュメントを目的の形式に変換するためのクラスです。
...の形式に変換するためのクラスです。
例:
require 'rdoc/markup/to_html'
h = RDoc::Markup::ToHtml.new
puts h.convert(input_string)
独自のフォーマットを行うようにパーサを拡張する事もできます。
例:
require 'rdoc/markup'
require 'rdoc/markup......m)
# :STRIKE のフォーマットを <strike> 〜 </strike> に指定。
wh.add_tag(:STRIKE, "<strike>", "</strike>")
puts "<body>#{wh.convert ARGF.read}</body>"
変換する形式を変更する場合、フォーマッタ(例. RDoc::Markup::ToHtml)
を変更、拡張する必要があり... -
OpenSSL
:: OCSP (12.0) -
OCSP(Online Certificate Status Protocol)を取り扱うための モジュールです。OCSP は 2560 で定義されています。
...plication/ocsp-request')
raise "HTTP error" if !httpres.kind_of?(Net::HTTPOK)
res = OpenSSL::OCSP::Response.new(httpres.body)
puts "Response status: #{res.status_string}"
exit if res.status != OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL
basic_resp = res.basic
raise "nonce error" unless...