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.
Defined Under Namespace
Classes: DuplicateKeyGroup, InvalidOption, InvalidValue
Constant Summary collapse
- OptionParserError =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Raised when option parsing fails
Class.new(StandardError)
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.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/justimmo_client/option_parser.rb', line 34 def initialize( = {}) = @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.
32 33 34 |
# File 'lib/justimmo_client/option_parser.rb', line 32 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.
31 32 33 |
# File 'lib/justimmo_client/option_parser.rb', line 31 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.
45 46 47 |
# File 'lib/justimmo_client/option_parser.rb', line 45 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.
49 50 51 52 53 |
# File 'lib/justimmo_client/option_parser.rb', line 49 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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/justimmo_client/option_parser.rb', line 55 def parse( = {}) out = {} .each do |key, value| raise InvalidOption, key unless .key?(key.to_sym) group = group_of(key) if group out[group] ||= {} out[group].update(parse_option(key.to_sym, value).reject { |_k, v| v.nil? }) else out.update(parse_option(key.to_sym, value).reject { |_k, v| v.nil? }) end end out end |