Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zonuexe/ruby-io-access_lazy
This gem provide lazy access method like array to IO object.
https://github.com/zonuexe/ruby-io-access_lazy
Last synced: about 2 months ago
JSON representation
This gem provide lazy access method like array to IO object.
- Host: GitHub
- URL: https://github.com/zonuexe/ruby-io-access_lazy
- Owner: zonuexe
- License: other
- Created: 2013-03-09T16:19:16.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-10T15:58:02.000Z (almost 12 years ago)
- Last Synced: 2024-10-27T05:21:45.738Z (about 2 months ago)
- Language: Ruby
- Homepage: https://rubygems.org/gems/io-access_lazy
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# IO::AccessLazy
*
さいふおとした。泣いてる。
* 回収されたらしい。世の中捨てたもんじゃない ヾ(〃><)ノ゙☆## Installation
Add this line to your application's Gemfile:
gem 'io-access_lazy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install io-access_lazy
## 日本語でおk (Japanese)
* IOオブジェクトから任意の行を遅延して取得します
* シェルスクリプティングだと `head(1)` とか `tail(1)` を使ってやるイメージです
* **タブンネ**## Usage
```ruby
fp = open("hoge.txt", 'r')
fp.read
# => "A
# B
# C
# D
# E
# F
# G
# H"
fp_lazy = IO::AccessLazy.new(fp)
line5 = fp_lazy[5]
# => "F"
line2_6 = fp_lazy[2..4]
# => ["C\n", "D\n", "E\n"]
line3_l = fp_lazy[3..-1]
# => ["D\n", "E\n", "F\n", "G\n", "H\n"]
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request