33件ヒット
[1-33件を表示]
(0.046秒)
検索結果
-
Enumerator
# feed(obj) -> nil (18226.0) -
Enumerator 内部の yield が返す値を設定します。
...Enumerator 内部の yield が返す値を設定します。
これで値を設定しなかった場合は yield は nil を返します。
この値は内部で yield された時点でクリアされます。
//emlist[例][ruby]{
# (1), (2), ... (10) の順に実行される
o = Object.new
def......# (5) => "foo"
x = yield # (6) blocks
p x # (8) => nil
x = yield # (9) blocks
p x # not reached w/o another e.next
end
e = o.to_enum
e.next # (1)
e.feed "foo" # (3)
e.next # (4)
e.next # (7)... -
rss (720.0)
-
RSS を扱うためのライブラリです。
...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, A......は RSS::Atom::Feed オブジェクト
をそれぞれ返します。パースした
String が well formed な XML で無い場合は,
例外 RSS::NotWellFormedError が発生します。well formed な
XML だが,RSS 0.9x/1.0/2.0, Atom のいずれでもない場合は,nil が
返ります......でパースするには以下のように書きます。
require 'rss'
rss = nil
begin
rss = RSS::Parser.parse(rss_source)
rescue RSS::InvalidRSSError
rss = RSS::Parser.parse(rss_source, false)
end
これは rss_source が RSS 0.9x/1.0/2.0 のどれか分からない時
にも... -
制御構造 (550.0)
-
制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END
...* until
* for
* break
* next
* redo
* retry
例外処理:
* raise
* begin
その他:
* return
* BEGIN
* END
Rubyでは(Cなどとは異なり)制御構造は式であって、何らかの値を返すものが
あります(返さないものもありま......節)の最後に評価し
た式の結果を返します。else 節がなくいずれの条件も成り立たなけれ
ば nil を返します。
Ruby では false または nil だけが偽で、それ以外は 0 や空文
字列も含め全て真です。
Ruby では if を繋げるのは elsif......。
条件が成立しなければ nil を返します。
====[a:unless] unless
//emlist[例][ruby]{
unless baby?
feed_meat
else
feed_milk
end
//}
文法:
unless 式 [then]
式 ...
[else
式 ... ]
end
unless は if と反対で、条件...