Class: TextExtractor::Guard
- Defined in:
- lib/text_extractor/guard.rb
Constant Summary collapse
- INDENTED =
{ description: 'indented line', block: proc { / ^[^\n\S]+[^\n]*$ / } }.freeze
- UNINDENTED =
{ description: 'unindented line', block: proc { / ^\S+[^\n]*$ / } }.freeze
- DEFAULT =
[ INDENTED, UNINDENTED ].freeze
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
- #extraction(match, _fill) ⇒ Object
-
#initialize(_regexp, description:, **kwargs) ⇒ Guard
constructor
A new instance of Guard.
Methods inherited from Record
#build_extraction, #build_regexp, #expand_regexp, #extract_fills, #extract_values, #ignore_regexp, #initialize_inline_values, #match, #options, #regexp_line_ignorer, #regexp_line_stripper, #source, #strip_regexp
Constructor Details
#initialize(_regexp, description:, **kwargs) ⇒ Guard
Returns a new instance of Guard.
5 6 7 8 |
# File 'lib/text_extractor/guard.rb', line 5 def initialize(_regexp, description:, **kwargs) super @description = description end |
Instance Method Details
#extraction(match, _fill) ⇒ Object
10 11 12 13 14 |
# File 'lib/text_extractor/guard.rb', line 10 def extraction(match, _fill) text = match[0] text = @factory.call(text) if @factory raise GuardError, "#{@description} near #{text.inspect}" end |