Class: RgGen::Core::InputBase::InputMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rggen/core/input_base/input_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern_or_patterns, **options, &converter) ⇒ InputMatcher

Returns a new instance of InputMatcher.



7
8
9
10
11
# File 'lib/rggen/core/input_base/input_matcher.rb', line 7

def initialize(pattern_or_patterns, **options, &converter)
  @options = options
  @converter = converter
  @patterns = format_patterns(pattern_or_patterns)
end

Instance Method Details

#match(rhs) ⇒ Object



13
14
15
16
17
18
# File 'lib/rggen/core/input_base/input_matcher.rb', line 13

def match(rhs)
  rhs
    .to_s
    .then { |s| ignore_blanks? && delete_blanks(s) || s }
    .then(&method(:match_patterns))
end

#match_automatically?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rggen/core/input_base/input_matcher.rb', line 20

def match_automatically?
  @options.fetch(:match_automatically, true)
end