Class: Commander::Command::Options

Inherits:
Object
  • Object
show all
Includes:
Blank
Defined in:
lib/commander/command.rb

Overview

Options struct.

Instance Method Summary collapse

Methods included from Blank

included

Constructor Details

#initializeOptions


16
17
18
# File 'lib/commander/command.rb', line 16

def initialize
  @table = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object


24
25
26
# File 'lib/commander/command.rb', line 24

def method_missing meth, *args, &block
  meth.to_s =~ /=$/ ? @table[meth.to_s.chop.to_sym] = args.first : @table[meth]
end

Instance Method Details

#__hash__Object


20
21
22
# File 'lib/commander/command.rb', line 20

def __hash__
  @table
end

#default(defaults = {}) ⇒ Object


28
29
30
# File 'lib/commander/command.rb', line 28

def default defaults = {}
  @table = defaults.merge! @table
end

#inspectObject


32
33
34
# File 'lib/commander/command.rb', line 32

def inspect
  "<Commander::Command::Options #{ __hash__.map { |k,v| "#{k}=#{v.inspect}" }.join(', ') }>"
end