Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Latest commit

 

History

History
67 lines (48 loc) · 2.23 KB

README.ja.rdoc

File metadata and controls

67 lines (48 loc) · 2.23 KB

each_section

github.com/kachick/each_section

DESCRIPTION

このライブラリは、 String, IO, StringIO クラスと ARGF に対し、#each_section と、これと同じ動きをする #setions というインスタンスメソッドを追加します。

String やら IO 等が持っている #each_line は便利な基本メソッドですよね。でも、区切り文字を $/ 以外に設定するとき、個人的に不満な箇所が2つあります。

  • その時点で line と言い難い-> 可読性が落ちる

  • 区切り文字に正規表現が使えない。-> これが使えるだけでも簡単なパーサなら作れるのに・・・

というシーンが良く有りました。なら作ってしまえということで生まれた小物ライブラリです。

SYNOPSIS

  • setup

    require 'each_section'
    
  • basic

    string.each_section /regexp/i do |section|
      do_something section
    end
    
  • enumerator

    enumerator = string.sections /regexp/i
    

REQUIREMENTS

Ruby

  • 1.9.3

  • 1.9.2

  • 1.8.7 ( 但し、 Object#require_relative というメソッドも追加します。 )

INSTALL

  • sudo gem install each_section

LICENSE

(The MIT License)

Copyright © 2010 Kenichi Kamiya

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.