るりまサーチ

最速Rubyリファレンスマニュアル検索!
80件ヒット [1-80件を表示] (0.023秒)
トップページ > クエリ:puts[x] > クエリ:fetch[x]

別のキーワード

  1. _builtin puts
  2. csv puts
  3. stringio puts
  4. zlib puts
  5. xmp puts

ライブラリ

クラス

キーワード

検索結果

Array#fetch(nth) -> object (18127.0)

nth 番目の要素を返します。

...しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts
err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

Array#fetch(nth) {|nth| ... } -> object (18127.0)

nth 番目の要素を返します。

...しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts
err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

Array#fetch(nth, ifnone) -> object (18127.0)

nth 番目の要素を返します。

...しなかった場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4, 5]
begin
p a.fetch(10)
rescue IndexError => err
puts
err #=> index 10 out of array
end

p a.fetch(10, 999) #=> 999

result = a.fetch(10){|nth|
print "#{nth} はありません。\n"
999
}
p result #=> 999
//}...

net/http (48.0)

汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。

...('/index.html')
}
puts
res.body
//}

//emlist[例4: 上の例よりさらに汎用的な例][ruby]{
require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts
res.body
//}

=...
...{'q'=>'ruby', 'max'=>'50'})
puts
res.body

#例2: 認証付きで POST する
res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'),
{'from'=>'2005-01-01', 'to'=>'2005-03-31'})
puts
res.body

#例3: より細かく制御する...
...==== リダイレクトに対応する
以下の例の fetch はリダイレクトに対応しています。
limit 回数以上リダイレクトしたらエラーにします。

//emlist[例][ruby]{
require 'net/http'
require 'uri'

def fetch(uri_str, limit = 10)
# You should choose better exc...

net/imap (42.0)

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

...'joe_user', 'joes_password')
imap.examine('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...
...icate("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.disconnect

とすると FETCH コマンドと SEARCH コマンドを並列に実行し...

絞り込み条件を変える

NKF (18.0)

nkf(Network Kanji code conversion Filter, https://osdn.net/projects/nkf/) を Ruby から使うためのモジュールです。

...KNOWN => "UNKNOWN",
}

while file = ARGV.shift
str = open(file) {|io| io.gets(nil) }

printf "%-10s ", file
if str.nil?
puts
"EMPTY"
else
puts
CODES.fetch(NKF.guess(str))
end
end
//}

=== オプション文字列

-b 入力がバッファリングされる(デフォルト)
-...

Thread#[](name) -> object | nil (12.0)

name に対応したスレッドに固有のデータを取り出します。 name に対応するスレッド固有データがなければ nil を返し ます。

...read.current["name"] = "A" },
Thread.new { Thread.current[:name] = "B" },
Thread.new { Thread.current["name"] = "C" }
].each do |th|
th.join
puts
"#{th.inspect}: #{th[:name]}"
end

# => #<Thread:0x00000002a54220 dead>: A
# => #<Thread:0x00000002a541a8 dead>: B
# => #<Thread:0x00000002a54130...
...rrent[:name]
# => nil if fiber-local
# => 2 if thread-local (The value 2 is leaked to outside of meth method.)
//}

Fiber を切り替えても同じ変数を返したい場合は
Thread#thread_variable_get と Thread#thread_variable_set
を使用してください。

@see Thread#fetch, Thread#[]=...