Sha256: 3d2fea06f76f779679f7e37459800d48b2ebc0d1bb2aadb7747e0e25342b37bb

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

module RProgram
  class OptionList < Hash

    #
    # Creates a new OptionList object with the given _options_.
    #
    def initialize(options={})
      super(options)
    end

    protected

    #
    # Provides transparent access to the options within the option list.
    #
    #   opt_list = OptionList.new(:name => 'test')
    #   opt_list.name
    #   # => "test"
    #
    def method_missing(sym,*args,&block)
      name = sym.to_s

      unless block
        if (name =~ /=$/ && args.length == 1)
          return self[name.chop.to_sym] = args.first
        elsif args.empty?
          return self[sym]
        end
      end

      return super(sym,*args,&block)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rprogram-0.1.6 lib/rprogram/option_list.rb