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

#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

#_replace_value(source_value, generated_value) ⇒ String

Parameters:

  • source_value (String)
  • generated_value (String)

Returns:

  • (String)


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

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

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

#_retrieve_value(source_value) ⇒ Object

gsub catchment group

Parameters:

  • source_value (String)


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