Class: Cure::Strategy::EndWithStrategy

Inherits:
BaseStrategy show all
Defined in:
lib/cure/strategy/end_with_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) ⇒ EndWithStrategy

Returns a new instance of EndWithStrategy.



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

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

Instance Attribute Details

#paramsEndWithStrategyParams

Additional details needed to make substitution.



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

def params
  @params
end

Instance Method Details

#_describeObject



34
35
36
37
38
# File 'lib/cure/strategy/end_with_strategy.rb', line 34

def _describe
  "End with replacement will look for '#{@params.match}'. " \
  "It will do a #{replace_partial_record ? "partial" : "full"} replacement. " \
  "[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
30
31
32
# File 'lib/cure/strategy/end_with_strategy.rb', line 25

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

  return generated_value unless replace_partial_record

  generated_value + @params.match
  # generated_value + source_value.reverse.chomp(@options["match"].reverse).reverse
end

#_retrieve_value(source_value) ⇒ Object

gsub catchment group

Parameters:



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

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