Sha256: c3d5926fe36fb020c5f0bba172bb05ec1351e1ca01012550c82bbaefc73089d3
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
# -*- coding: utf-8 -*- $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) module ReExpand VERSION = '0.0.2' end require 'Generator' require 'Node' require 'Asearch' require 'Scanner' class String # ExpandHelp用のライブラリを利用 def expand(filterpat=' ') g = ReExpand::Generator.new g.add(self,'') strings = [] if filterpat.class == String then matched = g.generate(filterpat) res = matched[0].length > 0 ? matched[0] : matched[1].length > 0 ? matched[1] : matched[2] strings = res.collect { |r| r[0] } elsif matched = g.generate(' ') strings = matched[0].collect { |r| r[0] } if filterpat.class == Regexp then strings = strings.find_all { |s| filterpat.match(s) } end end if block_given? then strings.each { |string| yield string } else strings end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
re_expand-0.0.2 | lib/re_expand.rb |