Class: Cure::Strategy::ContainStrategy

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

Returns a new instance of ContainStrategy.



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

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

Instance Attribute Details

#paramsContainStrategyParams

Additional details needed to make substitution.



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

def params
  @params
end

Instance Method Details

#_describeObject



32
33
34
35
# File 'lib/cure/strategy/contain_strategy.rb', line 32

def _describe
  "Replacing matched value on '#{@params.match}') " \
  "[Note: If the value does not include '#{@params.match}', no substitution is made.]"
end

#_replace_value(source_value, generated_value) ⇒ String

Parameters:

Returns:



26
27
28
29
30
# File 'lib/cure/strategy/contain_strategy.rb', line 26

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

Parameters:



17
18
19
20
21
# File 'lib/cure/strategy/contain_strategy.rb', line 17

def _retrieve_value(source_value)
  return unless source_value.include?(@params.match)

  @params.match
end