Module: Xqsr3::CommandLineUtilities::MapOptionString

Included in:
String
Defined in:
lib/xqsr3/command_line_utilities/map_option_string.rb

Overview

include-able module providing facilities for mapping strings to options

Components of interest

  • ::Xqsr3::CommandLineUtilities::MapOptionString.map_option_string_from_string

  • ::Xqsr3::CommandLineUtilities::MapOptionString#map_option_string

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object

:nodoc:

Raises:

  • (TypeError)


67
68
69
70
# File 'lib/xqsr3/command_line_utilities/map_option_string.rb', line 67

def self.included includer # :nodoc:

  raise TypeError, "module #{self} cannot be included into #{includer} because it does not respond to to_str" unless includer.method_defined? :to_str
end

.map_option_string_from_string(s, option_strings, options = {}) ⇒ Object

Attempts to translate the value of a given string according to a collection of options strings

Signature

  • Parameters:

    • s (::String) The string to be mapped

    • option_strings ([::String]) An array of strings against which the mapping will be performed

    • options (Hash) Options that control the behaviour of the method



128
129
130
131
# File 'lib/xqsr3/command_line_utilities/map_option_string.rb', line 128

def self.map_option_string_from_string s, option_strings, options = {}

  MapOptionString_Helper_.map_option_string_with_options_ s, option_strings, options
end

Instance Method Details

#map_option_string(option_strings, options = {}) ⇒ Object

Attempts to translate the (string) value of the receiver according to a collection of options strings

Signature

  • Parameters:

    • option_strings ([::String]) An array of strings against which the mapping will be performed



140
141
142
143
144
145
# File 'lib/xqsr3/command_line_utilities/map_option_string.rb', line 140

def map_option_string option_strings, options = {}

  s = self.kind_of?(::String) ? self : self.to_str

  MapOptionString_Helper_.map_option_string_with_options_ s, option_strings, options
end