Class: Cure::Strategy::MatchStrategy

Inherits:
BaseStrategy show all
Defined in:
lib/cure/strategy/match_strategy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseStrategy

#describe, #extract

Methods included from History

#history, #reset_history, #retrieve_history, #store_history

Constructor Details

#initialize(options) ⇒ MatchStrategy

Returns a new instance of MatchStrategy.



12
13
14
# File 'lib/cure/strategy/match_strategy.rb', line 12

def initialize(options)
  super(MatchStrategyParams.new(options))
end

Instance Attribute Details

#paramsMatchStrategyParams

Additional details needed to make substitution.

Returns:



10
11
12
# File 'lib/cure/strategy/match_strategy.rb', line 10

def params
  @params
end

Instance Method Details

#_describeObject



31
32
33
34
# File 'lib/cure/strategy/match_strategy.rb', line 31

def _describe
  "Match replacement will look for the presence of '#{@params.match}', and replace that value. " \
  "[Note: If the value does not include '#{@params.match}', no substitution is made.]"
end

#_replace_value(source_value, generated_value) ⇒ String

Parameters:

Returns:



25
26
27
28
29
# File 'lib/cure/strategy/match_strategy.rb', line 25

def _replace_value(source_value, generated_value)
  return source_value unless source_value.include? @params.match

  source_value.gsub(@params.match, generated_value)
end

#_retrieve_value(source_value) ⇒ Object

gsub catchment group

Parameters:



18
19
20
# File 'lib/cure/strategy/match_strategy.rb', line 18

def _retrieve_value(source_value)
  @params.match || nil if source_value.include? @params.match
end