Sha256: f5e03fac10b5cb7c820a34f9260575ee46b0aba47f373783863da26d1326b1ef

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8
#
# USAGE: textfilter [options] str0 str1 files ...

require "pp"
require "optparse"
require "rubygems"
gem "tefil"
require "tefil.rb"

## option analysis
OPTIONS = {}
op = OptionParser.new
op.on("-s"    , "--sort"    , "Sort."){    OPTIONS[:sort] = true}
op.on("-r"    , "--randomize" , "Randomize."){    OPTIONS[:random] = true}
op.on("-o"    , "--overwrite"    , "Overwrite."){    OPTIONS[:overwrite] = true}
op.parse!(ARGV)

module TextFilter
	def self.process_stream(in_io, out_io)
		in_io.each do |line|
			if OPTIONS[:sort]
				out_io.puts line.chomp.split(//).sort.join('')
			end
			if OPTIONS[:random]
				out_io.puts line.chomp.split(//).sort_by{rand}.join('')
			end
		end
	end
end

OPTIONS[:overwrite] ||= false


#pp OPTIONS[:overwrite]
#TextFilter.run(ARGV, OPTIONS[:overwrite])
TextFilter.run(ARGV, OPTIONS[:overwrite])

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tefil-0.0.0 bin/lineedit