Class: Cure::Strategy::RegexStrategy

Inherits:
Base
  • Object
show all
Defined in:
lib/cure/strategy/base.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#extract, #initialize

Methods included from History

#history, #reset_history, #retrieve_history, #store_history

Constructor Details

This class inherits a constructor from Cure::Strategy::Base

Instance Method Details

#_replace_value(source_value, generated_value) ⇒ String

Parameters:

  • source_value (String)
  • generated_value (String)

Returns:

  • (String)


131
132
133
134
135
136
137
138
# File 'lib/cure/strategy/base.rb', line 131

def _replace_value(source_value, generated_value)
  m = /#{@options["regex_cg"]}/.match(source_value)
  return unless m.instance_of?(MatchData) && (!m[1].nil? && m[1] != "")

  generated_value unless replace_partial_record

  source_value.gsub(m[1], generated_value)
end

#_retrieve_value(source_value) ⇒ Object

gsub catchment group

Parameters:

  • source_value (String)


121
122
123
124
125
126
# File 'lib/cure/strategy/base.rb', line 121

def _retrieve_value(source_value)
  m = /#{@options["regex_cg"]}/.match(source_value)
  return unless m.instance_of?(MatchData) && (!m[1].nil? && m[1] != "")

  m[1]
end