るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

キーワード

検索結果

open-uri (6115.0)

http/ftp に簡単にアクセスするためのクラスです。 Kernel.#open を再定義します。

...義します。

=== 使用例

http/ftp の URL を、普通のファイルのように開けます。

require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開いたファイルオブジェクトは StringIO もしくは Tempfile で
すが OpenURI::Me...
...えます。

require 'open-uri'
open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding # []...
...加のヘッダフィールドを指定できます。

require 'open-uri'
open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "http://www.ruby-lang.org/") {|f|
...
}

http_proxy, ftp_proxy, no_proxy などの...
...ラスです。

=== 使用例

http/ftp の URL を、普通のファイルのように開けます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

開いたファイルオブジェクトは StringIO もしくは Tempfile で
すが OpenURI...
...えます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/en") {|f|
f.each_line {|line| p line}
p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/>
p f.content_type # "text/html"
p f.charset # "iso-8859-1"
p f.content_encoding...
...のヘッダフィールドを指定できます。

require 'open-uri'
URI.open("http://www.ruby-lang.org/en/",
"User-Agent" => "Ruby/#{RUBY_VERSION}",
"From" => "foo@bar.invalid",
"Referer" => "http://www.ruby-lang.org/") {|f|
...
}

http_proxy, ftp_proxy, no_proxy などの...

pp (169.0)

オブジェクトなどを見やすく出力するためのライブラリです。

...etty-print されてない出力:
#<PP:0x81a0d10 @stack=[], @genspace=#<Proc:0x81a0cc0>, @nest=[0], @newline="\n",
@buf=#<PrettyPrint::Group:0x81a0c98 @group=0, @tail=0, @buf=[#<PrettyPrint::Gro
up:0x81a0ba8 @group=1, @tail=0, @buf=[#<PrettyPrint::Text:0x81a0b30 @tail=2, @wi
dth=1, @text="[...
...">, #<PrettyPrint::Group:0x81a0a68 @group=2, @tail=1, @buf=[#<Pre
ttyPrint::Text:0x81a09f0 @tail=1, @width=1, @text="1">], @singleline_width=1>, #
<PrettyPrint::Text:0x81a0a7c @tail=0, @width=1, @text=",">, #<PrettyPrint::Break
able:0x81a0a2c @group=2, @gensace=#<Proc:0x81a0cc0>, @newline="\n"...
...2, @tail=1, @
buf=[#<PrettyPrint::Text:0x81a0950 @tail=1, @width=1, @text="2">], @singleline_w
idth=1>, #<PrettyPrint::Text:0x81a0af4 @tail=0, @width=1, @text="]">], @singleli
ne_width=6>], @singleline_width=6>, @sharing_detection=false>

pp による pretty-print された出力:
#<PP:0x40d...

rss (169.0)

RSS を扱うためのライブラリです。

...す。

=== 参考

* RSS 0.91 http://backend.userland.com/rss091
* RSS 1.0 http://purl.org/rss/1.0/spec
* RSS 2.0 http://www.rssboard.org/rss-specification
* Atom 1.0 https://www.ietf.org/rfc/rfc4287.txt

=== 注意

RSS ParserはRSS 0.9x/1.0/2.0, Atom 1.0 をサポートしています...
...が子要素または属性を持つ場合も同様です。

rss = RSS::Parser.parse(rss_source)
rss.channel.description # => /rdf:RDF/channel/text(); String

属性にアクセスする時も同様です。channel要素のrdf:about属性に
アクセスするには以下のようにします...
...を作成する

* 出力エンコーディングを指定する(省略可)

* RSSオブジェクトのto_sメソッドを呼ぶ

==== xml-stylesheet

xml-stylesheetも出力することができます.

RSSのルート要素(RSS::RDFまたはRSS::Rss)オブジェ
クトおよびAtomのル...

net/imap (127.0)

このライブラリは Internet Message Access Protocol (IMAP) の クライアントライブラリです。2060 を元に 実装されています。

...e('INBOX')
imap.search(["RECENT"]).each do |message_id|
envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
puts "#{envelope.from[0].name}: \t#{envelope.subject}"
end

2003年4月のメールをすべて Mail/sent-mail から "Mail/sent-apr03" へ移動させる

require...
...', 'joes_password')
imap.select('Mail/sent-mail')
if not imap.list('Mail/', 'sent-apr03')
imap.create('Mail/sent-apr03')
end
imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
imap.copy(message_id, "Mail/sent-apr03")
imap.store(message_id, "+FLAGS"...
...

require 'net/imap'

imap = Net::IMAP.new("imap.foo.net", "imap2")
imap.authenticate("cram-md5", "bar", "password")
imap.select("inbox")
fetch_thread = Thread.start { imap.fetch(1..-1, "UID") }
search_result = imap.search(["BODY", "hello"])
fetch_result = fetch_thread.value
imap....

webrick/cgi (25.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...
...']
req.query['num']
end
end
MyCGI.new.start()

同じ名前のフィールドが複数ある場合、list メソッドや each_data メソッドを使います。

require "webrick/cgi"
class MyCGI < WEBrick::CGI
def do_GET(req, res)
req.query['q'].list #=>...
...d.name #=> "field_name"
d.filename #=> もしあればファイル名を返す。
d['content-type'] #=> ヘッダの値は [] メソッドで取得する
d #=> 送られてきたファイルの中...

絞り込み条件を変える