Sha256: c9d19522d99a94086fdb74864fac1b344c1f1d11d5f65d7544829443f3eb776f

Contents?: true

Size: 392 Bytes

Versions: 13

Compression:

Stored size: 392 Bytes

Contents

module ArgsParser
  class Filter
    def filters
      @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

13 entries across 13 versions & 1 rubygems

Version Path
args_parser-0.1.6 lib/args_parser/filter.rb
args_parser-0.1.5 lib/args_parser/filter.rb
args_parser-0.1.4 lib/args_parser/filter.rb
args_parser-0.1.3 lib/args_parser/filter.rb
args_parser-0.1.2 lib/args_parser/filter.rb
args_parser-0.1.1 lib/args_parser/filter.rb
args_parser-0.1.0 lib/args_parser/filter.rb
args_parser-0.0.10 lib/args_parser/filter.rb
args_parser-0.0.9 lib/args_parser/filter.rb
args_parser-0.0.8 lib/args_parser/filter.rb
args_parser-0.0.7 lib/args_parser/filter.rb
args_parser-0.0.6 lib/args_parser/filter.rb
args_parser-0.0.5 lib/args_parser/filter.rb