Sha256: 8e1f4c05c5575bfe93aa8e87d7ad5841990121480c7d863917835b7cecd6d212

Contents?: true

Size: 440 Bytes

Versions: 3

Compression:

Stored size: 440 Bytes

Contents

require 'ostruct'

module GLI
  # Subclass of +OpenStruct+ that provides hash-like methods for #[] and #[]=.  Note that is is *not* a Hash.
  # By using GLI::App#use_openstruct, your options will be coerced into one of these.
  class Options < OpenStruct

    # Return the value of an attribute
    def[](k)
      @table[k.to_sym]
    end

    # Set the value of an attribute
    def[]=(k, v)
      @table[k.to_sym] = v
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gli-2.0.0.rc5 lib/gli/options.rb
gli-2.0.0.rc4 lib/gli/options.rb
gli-2.0.0.rc3 lib/gli/options.rb