Sha256: f308fa58730a1bbc2fb0476beca32dc8084899fec3ce1d1ef444e80b1caef141

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

require 'rprogram/extensions/hash'

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[0]
        elsif args.length==0
          return self[sym]
        end
      end

      super(sym,*args,&block)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rprogram-0.1.5 lib/rprogram/option_list.rb
rprogram-0.1.4 lib/rprogram/option_list.rb