るりまサーチ

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

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

Addrinfo.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=0) {|addrinfo| ... } -> [Addrinfo] (21402.0)

Addrinfo.getaddrinfo で得られる配列の各要素を繰り返します。

...
Add
rinfo.getaddrinfo で得られる配列の各要素を繰り返します。

ブロックを省略した場合は Enumerator を返します。

@param nodename ノード名文字列(ホスト名もしくは IP アドレス)
@param service サービス名(文字列もしくはポート番号の...

Addrinfo.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=0) -> Enumerator (21202.0)

Addrinfo.getaddrinfo で得られる配列の各要素を繰り返します。

...
Add
rinfo.getaddrinfo で得られる配列の各要素を繰り返します。

ブロックを省略した場合は Enumerator を返します。

@param nodename ノード名文字列(ホスト名もしくは IP アドレス)
@param service サービス名(文字列もしくはポート番号の...

Net::POP3.foreach(address, port = nil, account, password, isapop=false) {|mail| .... } -> () (18307.0)

POP セッションを開始し、 サーバ上のすべてのメールを取りだし、 個々のメールを引数としてブロックを呼びだします。

...同様の処理をします。
require 'net/pop'

Net::POP3.start(address, port, account, password, isapop=false) {|pop|
pop.each_mail do |m|
yield m
end
}

使用例:

require 'net/pop'

Net::POP3.foreach('pop.example.com', 110,
'YourAccount', 'YourPass...
...word') do |m|
file.write m.pop
m.delete if $DELETE
end

@param address POP3サーバのホスト名文字列
@param port 接続するPOP3サーバのポート番号
@param account アカウント名文字列
@param password パスワード文字列
@param isapop 真でAPOPを利用しま...

Addrinfo.getaddrinfo(nodename, service, family=nil, socktype=nil, protocol=nil, flags=0) -> [Addrinfo] (9306.0)

パラメータから複数の Addrinfo オブジェクトを生成し、その配列を返します。

...パラメータから複数の Addrinfo オブジェクトを生成し、その配列を返します。

nodename (ホスト名) と service (ポート番号) を Addrinfo に変換します。
変換先は一意ではないため、複数のオブジェクトを返します。

nodename と service...
...cktype なしでは曖昧な指定となるためです。

例:

require 'socket'

Add
rinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
#=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net:80)>,
# #<Addrinfo: [2001:200:0:8002:203:47ff:fea5:3085]:80 TCP (www.kame.net:80)>]

@param node...
...ケットタイプ(整数、文字列、シンボル、もしくは nil)
@param protocol プロトコル(整数、もしくは nil)
@param flags フラグ(整数)

@raise SocketError getaddrinfo(3)がエラーを返したときに発生する例外です
@see Addrinfo.foreach, Socket.getaddrinfo...

Enumerable#chunk {|elt| ... } -> Enumerator (172.0)

要素を前から順にブロックで評価し、その結果によって 要素をチャンクに分けた(グループ化した)要素を持つ Enumerator を返します。

...st[例][ruby]{
# ファイルのエンコーディングは実際のファイルに合わせてください。
open("/usr/share/dict/words", "r:iso-8859-1") {|f|
f.chunk {|line| line[0].upcase }.each {|ch, lines| p [ch, lines.length] }
}
# => ["A", 17096]
# ["B", 11070]
# ["C", 19901]
# [...
..."r20018 | knu | 2008-10-29 13:20:42 +0900 (Wed, 29 Oct 2008) | 2 lines\n",
# "\n",
# "* README, README.ja: Update the portability section.\n",
# "\n"]
# ["r16725 | knu | 2008-05-31 23:34:23 +0900 (Sat, 31 May 2008) | 2 lines\n",
# "\n",
# "* README, README.ja: Add a note about defau...
...# "\n"]
# ...
//}

テキストを空行で区切られた段落に分けたい場合にも nil が使えます。

//emlist[例][ruby]{
File.foreach("README").chunk {|line|
/\A\s*\z/ !~ line || nil
}.each {|_, lines|
pp lines
}
//}

「:_alone」は要素を素通ししたい場合に用...

絞り込み条件を変える

logger (108.0)

ログを記録するためのライブラリです。

...ger::WARN

logger.debug("Created logger")
logger.info("Program started")
logger.warn("Nothing to do!")

path = "a_non_existent_file"

begin
File.foreach(path) do |line|
unless line =~ /^(\w+) = (.*)$/
logger.error("Line in wrong format: #{line.chomp}")
end
end
rescue => err
logge...
...17-12-07T02:22:53.649000 #11601] WARN -- : Nothing to do!
F, [2017-12-07T02:22:53.649172 #11601] FATAL -- : Caught exception; exiting
F, [2017-12-07T02:22:53.649222 #11601] FATAL -- : No such file or directory @ rb_sysopen - a_non_existent_file (Errno::ENOENT)
logger_sample.rb:12:in `foreach'...
...or、
Logger#warn、Logger#info、Logger#debug メソッドを使用
します。動的に任意のログレベルを設定したい場合は Logger#add を使
用します。

1. ブロックを指定

//emlist[][ruby]{
logger.fatal { "Argument 'foo' not given." }
//}

2. 文字列を指定

//emli...