class Object

Constants

USAGE

Public Instance Methods

make_regex(*args) click to toggle source
# File bin/ese, line 72
def make_regex(*args)
        args.flatten!
        if args.length==1 # $mode != :sub
                options = {i: 1, x: 2, m: 4}
                options_str = args.first.split("/").last.split("")
                option_bits = options.to_a.select{|i|options_str.include? i[0].to_s}.to_h.values.sum
                Regexp.new(args.first, option_bits)
        else # $mode.to_s.match /^g?sub$/
                options = {i: 1, x: 2, m: 4}
                options_str = args[3].split("")
                option_bits = options.to_a.select{|i|options_str.include? i[0].to_s}.to_h.values.sum
                Regexp.new(args[1], option_bits)
        end
end
parse_mode(mode) click to toggle source

abort(USAGE)

# File bin/ese, line 52
def parse_mode(mode)
        $mode = case mode
        when "-i","include"
                :include
        when "-x","exclude"
                :exclude
        when "-f","find"
                :find
        when "-s","sub"
                :sub
        when "-g","gsub"
                :gsub
        when "-h","help"
                puts USAGE
                exit 0
        else
                abort( "\nUnknown option '#{mode}'\n" << USAGE )
        end
end