Sha256: 2f532fe958cc857a6119691856b9ed87c45faf17d67ac76a4317526606123e0f
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
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.1' end require 'Generator' require 'Node' require 'Asearch' require 'Scanner' class String # ExpandHelp用のライブラリを利用 def expand(filterpat=' ') g = 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.1 | lib/re_expand.rb |