bitclust v1.8.0 をリリースしました。
特筆すべき変更点
DB が無いとき refe コマンドと irb の refe に docs.ruby-lang.org を引くリモート検索を追加しました。
v1.7.0 までは bitclust setup で bitclust の DB を作成する必要がありましたが、 DB がないと自動的に Ruby リファレンスマニュアル 検索 の索引をダウンロードして、メソッドなどのドキュメントも md ファイルを自動ダウンロードして表示できるようになりました。
自動ダウンロードできるのは最新安定版だけなので、他のバージョンを指定したかったり、 オフラインでも使えるようにしたりするには、今まで通り bitclust setup を使ってください。
% refe each_with_index
Enumerable#each_with_index Matrix#each_with_index
Prime::PseudoPrimeGenerator#each_with_index
refe E each_with_index
# Enumerable#each_with_index
### def each_with_index(*args) -> Enumerator
### def each_with_index(*args) {|item, index| ... } -> self
要素とそのインデックスをブロックに渡して繰り返します。
ブロックを省略した場合は、要素とそのインデックスを繰り返すような
[Enumerator](../../../class/Enumerator.md) を返します。
[Enumerator#with_index](../../../method/Enumerator/i/with_index.md) は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにそのまま渡されます)。
- **param** `args` -- イテレータメソッド (each など) にそのまま渡されます。
```ruby title="例"
[5, 10, 15].each_with_index do |n, idx|
p [n, idx]
end
# => [5, 0]
# [10, 1]
# [15, 2]
```
```ruby title="引数ありの例"
require 'stringio'
StringIO.new("foo|bar|baz").each_with_index("|") do |s, i|
p [s, i]
end
# => ["foo|", 0]
# ["bar|", 1]
# ["baz", 2]
```
- **SEE** [Enumerator#with_index](../../../method/Enumerator/i/with_index.md)
---
https://docs.ruby-lang.org/ja/latest/method/Enumerable/i/each_with_index.html
(docs.ruby-lang.org から取得しました。手元で検索するには bitclust setup で DB を作成してください)
bitclust-irb gem
v1.7.0 から irb から るりま を引く refe コマンドを追加する bitclust-irb gem をリリースしています。
bitclust-irb gem を入れて ~/.irbrc に require "bitclust/irb" を追記すると使えるようになります。
>> refe String#gsub
>> refe Array.new
>> refe Comparable
irb 側の hook が入れば、 対応している irb と対応している bitclust-irb の組み合わせで rdoc の代わりに rurema の内容が表示できるようになる予定です。
最後に
Markdown のるりま拡張の書式は、まだ時々不足がみつかって変更が入っているので、 doctree の方も bitclust のリリース数日後に REQUIRED_BITCLUST_VERSION の更新 をして、新しい書式を使えるようにしています。
新しい書式でエラーになって、エラーメッセージで更新を促されたときは bitclust 関係の gem を更新してください。