Class: Cure::Strategy::ContainStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- Cure::Strategy::ContainStrategy
- Defined in:
- lib/cure/strategy/contain_strategy.rb
Instance Attribute Summary collapse
-
#params ⇒ ContainStrategyParams
Additional details needed to make substitution.
Instance Method Summary collapse
- #_describe ⇒ Object
- #_replace_value(source_value, generated_value) ⇒ String
- #_retrieve_value(source_value) ⇒ Object
-
#initialize(options) ⇒ ContainStrategy
constructor
A new instance of ContainStrategy.
Methods inherited from BaseStrategy
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() super(ContainStrategyParams.new()) end |
Instance Attribute Details
#params ⇒ ContainStrategyParams
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
#_describe ⇒ Object
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
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
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 |