Class: Regexer::Utils::Handlers::AnyCharacterInInputValueHandlers::FromToHashHandler
- Inherits:
-
Base
- Object
- BaseHandler
- Base
- Regexer::Utils::Handlers::AnyCharacterInInputValueHandlers::FromToHashHandler
- Defined in:
- lib/regexer/utils/handlers/any_character_in_input_value_handlers/from_to_hash_handler.rb
Overview
A handler class to check if input value is a Hash with from & to keys only if true, should return a regex escaped string based on values in that Hash
Instance Method Summary collapse
Methods inherited from Base
#give_to_next_handler, #next_handler
Methods inherited from BaseHandler
Instance Method Details
#handle(value) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/regexer/utils/handlers/any_character_in_input_value_handlers/from_to_hash_handler.rb', line 14 def handle(value) if value.instance_of?(Hash) && value.keys == %i[from to] Regexer::Validators::FromToValidator.valid_values?("ascii_character", value[:from], value[:to]) "#{Regexp.escape(value[:from])}-#{Regexp.escape(value[:to])}" else give_to_next_handler(value) end end |