Class: RgGen::Options

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rggen/options.rb

Defined Under Namespace

Classes: OptionSwitch

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Forwardable

def_class_delegator, def_class_delegators

Constructor Details

#initializeOptions

Returns a new instance of Options.



74
75
76
# File 'lib/rggen/options.rb', line 74

def initialize
  @options  = Hash.new { |h, k| h[k]  = option_switches[k].default }
end

Class Method Details

.add_option_switch(kind, &block) ⇒ Object



65
66
67
68
# File 'lib/rggen/options.rb', line 65

def add_option_switch(kind, &block)
  option_switches[kind] = OptionSwitch.new(kind)
  option_switches[kind].instance_exec(&block)
end

.option_switchesObject



61
62
63
# File 'lib/rggen/options.rb', line 61

def option_switches
  @option_switches ||= {}
end

.parse(args) ⇒ Object



57
58
59
# File 'lib/rggen/options.rb', line 57

def parse(args)
  new.tap { |options| options.parse(args) }
end

Instance Method Details

#parse(args) ⇒ Object



78
79
80
# File 'lib/rggen/options.rb', line 78

def parse(args)
  option_parser.parse!(args)
end