Sha256: bdf41f1c0feaac20157e0adb08c4279ec6295296305baf07702c1cf221fb56f2

Contents?: true

Size: 419 Bytes

Versions: 1

Compression:

Stored size: 419 Bytes

Contents

module ArgsParser
  class Filter

    attr_reader :filters

    def initialize
      @filters = []
    end

    def add(name, filter)
      name = name.to_sym if name
      filters.push({:name => name, :filter => filter})
    end

    def filter(name, value)
      filters.each do |f|
        if !f[:name] or f[:name] == name
          value = f[:filter].call(value)
        end
      end
      value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
args_parser-0.2.0 lib/args_parser/filter.rb