Module: Quickl::Command::Options::ClassMethods
- Defined in:
- lib/quickl/command/options.rb
Instance Attribute Summary collapse
-
#option_builders ⇒ Object
readonly
Installed options builders.
Instance Method Summary collapse
-
#build_options(scope = self) ⇒ Object
Builds an OptionParser instance.
-
#options(builder = nil, &block) ⇒ Object
Without builder nor block, returns built options.
-
#summarized_options ⇒ Object
Returns summarized options.
Instance Attribute Details
#option_builders ⇒ Object (readonly)
Installed options builders
6 7 8 |
# File 'lib/quickl/command/options.rb', line 6 def option_builders @option_builders end |
Instance Method Details
#build_options(scope = self) ⇒ Object
Builds an OptionParser instance
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/quickl/command/options.rb', line 9 def (scope = self) OptionParser.new do |opt| opt.program_name = File.basename $0 if const_defined?(:VERSION) opt.version = const_get(:VERSION) end opt.summary_indent = ' ' * 2 (option_builders || []).each{|b| scope.instance_exec(opt, &b) } end end |
#options(builder = nil, &block) ⇒ Object
Without builder nor block, returns built options. Otherwise, adds a new option builder
24 25 26 27 28 29 30 31 |
# File 'lib/quickl/command/options.rb', line 24 def (builder = nil, &block) if b = (builder || block) @option_builders ||= [] @option_builders << b else end end |
#summarized_options ⇒ Object
Returns summarized options
34 35 36 |
# File 'lib/quickl/command/options.rb', line 34 def .summarize.join.rstrip end |