Sha256: 81a62d7f3aa439eac8daa649d2bfae67cd02682277df5b75ffa43ff7482bd7d1
Contents?: true
Size: 1 KB
Versions: 5
Compression:
Stored size: 1 KB
Contents
# -*- coding: utf-8 -*- # # @file # @brief grenwebで使用する行指向の検索 # @author ongaeshi # @date 2010/10/18 module Grenweb class Grep attr_reader :content def initialize(content) @content = content.split("\n") end MatchLineResult = Struct.new(:index, :match_datas) def match_lines_or(patterns) result = [] patternRegexps = strs2regs(patterns, true) # @todo ignoreオプションを付ける @content.each_with_index do |line, index| match_datas = [] patternRegexps.each {|v| match_datas << v.match(line)} if (match_datas.any?) result << MatchLineResult.new(index, match_datas) end end result end def context(result, num) end private def strs2regs(strs, ignore = false) regs = [] strs.each do |v| option = 0 option |= Regexp::IGNORECASE if (ignore) regs << Regexp.new(v, option) end regs end end end
Version data entries
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
codestock-0.1.1 | lib/cdweb/grep.rb |
codestock-0.1.0 | lib/grenweb/grep.rb |
gren-0.3.2 | lib/grenweb/grep.rb |
gren-0.3.1 | lib/grenweb/grep.rb |
gren-0.3.0 | lib/grenweb/grep.rb |