Class: Cure::Strategy::StartWithStrategy

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

Returns a new instance of StartWithStrategy.



14
15
16
# File 'lib/cure/strategy/start_with_strategy.rb', line 14

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

Instance Attribute Details

#paramsStartWithStrategyParams

Additional details needed to make substitution.



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

def params
  @params
end

Instance Method Details

#_describeObject



35
36
37
38
39
# File 'lib/cure/strategy/start_with_strategy.rb', line 35

def _describe
  "Start 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:



27
28
29
30
31
32
33
# File 'lib/cure/strategy/start_with_strategy.rb', line 27

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

  return generated_value unless replace_partial_record

  @params.match + generated_value
end

#_retrieve_value(source_value) ⇒ Object

gsub catchment group

Parameters:



20
21
22
# File 'lib/cure/strategy/start_with_strategy.rb', line 20

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