Class: Regexer::Utils::QuantifierValueGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/regexer/utils/quantifier_value_generator.rb

Overview

A Utility Class that generates a quantifier value based on the given options

Class Method Summary collapse

Class Method Details

.generate(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/regexer/utils/quantifier_value_generator.rb', line 13

def self.generate(value)
  exactly_option_handler = ::Regexer::Utils::Handlers::QuantifierOptionsHandler::ExactlyOptionHandler.new
  minimum_option_handler = ::Regexer::Utils::Handlers::QuantifierOptionsHandler::MinimumOptionHandler.new
  min_max_option_handler = ::Regexer::Utils::Handlers::QuantifierOptionsHandler::MinMaxOptionHandler.new
  no_option_handler = ::Regexer::Utils::Handlers::QuantifierOptionsHandler::NoOptionHandler.new

  exactly_option_handler.next_handler(minimum_option_handler)
                        .next_handler(min_max_option_handler)
                        .next_handler(no_option_handler)

  exactly_option_handler.handle(value) || ""
end