Module: Anyway::OptparseConfig::ClassMethods
- Defined in:
- lib/anyway/optparse_config.rb
Instance Method Summary collapse
- #describe_options(**hargs) ⇒ Object
- #extend_options(&block) ⇒ Object
- #flag_options(*args) ⇒ Object
- #ignore_options(*args) ⇒ Object
- #option_parser_descriptors ⇒ Object
- #option_parser_extensions ⇒ Object
- #option_parser_options ⇒ Object
Instance Method Details
#describe_options(**hargs) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/anyway/optparse_config.rb', line 20 def (**hargs) hargs.each do |name, desc| if String === desc option_parser_descriptors[name.to_s][:desc] = desc else option_parser_descriptors[name.to_s].merge!(desc) end end end |
#extend_options(&block) ⇒ Object
36 37 38 |
# File 'lib/anyway/optparse_config.rb', line 36 def (&block) option_parser_extensions << block end |
#flag_options(*args) ⇒ Object
30 31 32 33 34 |
# File 'lib/anyway/optparse_config.rb', line 30 def (*args) args.each do |name| option_parser_descriptors[name.to_s][:flag] = true end end |
#ignore_options(*args) ⇒ Object
14 15 16 17 18 |
# File 'lib/anyway/optparse_config.rb', line 14 def (*args) args.each do |name| option_parser_descriptors[name.to_s][:ignore] = true end end |
#option_parser_descriptors ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/anyway/optparse_config.rb', line 60 def option_parser_descriptors return @option_parser_descriptors if instance_variable_defined?(:@option_parser_descriptors) @option_parser_descriptors = if superclass < Anyway::Config superclass.option_parser_descriptors.deep_dup else Hash.new { |h, k| h[k] = {} } end end |
#option_parser_extensions ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/anyway/optparse_config.rb', line 49 def option_parser_extensions return @option_parser_extensions if instance_variable_defined?(:@option_parser_extensions) @option_parser_extensions = if superclass < Anyway::Config superclass.option_parser_extensions.dup else [] end end |
#option_parser_options ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/anyway/optparse_config.rb', line 40 def config_attributes.each_with_object({}) do |key, result| descriptor = option_parser_descriptors[key.to_s] next if descriptor[:ignore] == true result[key] = descriptor end end |