Class: JustimmoClient::OptionParser Private
- Inherits:
-
Object
- Object
- JustimmoClient::OptionParser
- Includes:
- Logging
- Defined in:
- lib/justimmo_client/option_parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #mappings ⇒ Object private
- #range_suffix ⇒ Object private
Instance Method Summary collapse
- #add(key, **options, &block) ⇒ Object private
- #group(groupname) {|_self| ... } ⇒ Object private
-
#initialize(options = {}) {|_self| ... } ⇒ OptionParser
constructor
private
A new instance of OptionParser.
- #parse(options = {}) ⇒ Object private
Methods included from Logging
default_logger, #logger, rails_logger
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ OptionParser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OptionParser.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/justimmo_client/option_parser.rb', line 11 def initialize( = {}) @options = @mappings = {} @range_suffix = %i[_min _max] @context = nil yield self if block_given? parse unless .empty? end |
Instance Attribute Details
#mappings ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/justimmo_client/option_parser.rb', line 9 def mappings @mappings end |
#range_suffix ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/justimmo_client/option_parser.rb', line 8 def range_suffix @range_suffix end |
Instance Method Details
#add(key, **options, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 |
# File 'lib/justimmo_client/option_parser.rb', line 22 def add(key, **, &block) add_option(key, , &block) end |
#group(groupname) {|_self| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/justimmo_client/option_parser.rb', line 26 def group(groupname) @context = groupname.to_sym yield self if block_given? @context = nil end |
#parse(options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/justimmo_client/option_parser.rb', line 32 def parse( = {}) out = {} .each do |key, value| raise JustimmoClient::InvalidOption, key unless @options.key?(key.to_sym) group = group_of(key) if group out[group] ||= {} out[group].update(parse_option(key.to_sym, value)) else out.update(parse_option(key.to_sym, value)) end end out end |