Sha256: d64952e8f3c5d91458939172bf51c89bc979ab8f9cfa67c844ce038352da9e7f

Contents?: true

Size: 503 Bytes

Versions: 11

Compression:

Stored size: 503 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)
      self.send(k.to_sym)
    end

    # Set the value of an attribute
    def[]=(k, v)
      self.send("#{k.to_sym}=",v)
    end

    def map(&block)
      @table.map(&block)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gli-2.22.2 lib/gli/options.rb
gli-2.22.1 lib/gli/options.rb
gli-2.22.0 lib/gli/options.rb
gli-2.21.5 lib/gli/options.rb
gli-2.21.4 lib/gli/options.rb
gli-2.21.3 lib/gli/options.rb
gli-2.21.2 lib/gli/options.rb
gli-2.21.1 lib/gli/options.rb
gli-2.21.0 lib/gli/options.rb
gli-2.20.1 lib/gli/options.rb
gli-2.20.0 lib/gli/options.rb