Class: Cure::Strategy::RegexStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- Cure::Strategy::RegexStrategy
- Defined in:
- lib/cure/strategy/regex_strategy.rb
Instance Attribute Summary collapse
-
#params ⇒ RegexStrategyParams
Additional details needed to make substitution.
Instance Method Summary collapse
- #_describe ⇒ Object
- #_replace_value(source_value, generated_value) ⇒ String
-
#_retrieve_value(source_value) ⇒ Object
gsub catchment group.
-
#initialize(options) ⇒ RegexStrategy
constructor
A new instance of RegexStrategy.
Methods inherited from BaseStrategy
Methods included from History
#history, #reset_history, #retrieve_history, #store_history
Constructor Details
#initialize(options) ⇒ RegexStrategy
Returns a new instance of RegexStrategy.
12 13 14 |
# File 'lib/cure/strategy/regex_strategy.rb', line 12 def initialize() super(RegexStrategyParams.new()) end |
Instance Attribute Details
#params ⇒ RegexStrategyParams
Additional details needed to make substitution.
10 11 12 |
# File 'lib/cure/strategy/regex_strategy.rb', line 10 def params @params end |
Instance Method Details
#_describe ⇒ Object
37 38 39 40 |
# File 'lib/cure/strategy/regex_strategy.rb', line 37 def _describe "Matching on '#{@params.regex_cg}'. " \ "[Note: If the regex does not match, or has no capture group, no substitution is made.]" end |
#_replace_value(source_value, generated_value) ⇒ String
28 29 30 31 32 33 34 35 |
# File 'lib/cure/strategy/regex_strategy.rb', line 28 def _replace_value(source_value, generated_value) m = /#{@params.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
18 19 20 21 22 23 |
# File 'lib/cure/strategy/regex_strategy.rb', line 18 def _retrieve_value(source_value) m = /#{@params.regex_cg}/.match(source_value) return unless m.instance_of?(MatchData) && (!m[1].nil? && m[1] != "") m[1] end |