Class: Cure::Strategy::SplitStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- Cure::Strategy::SplitStrategy
- Defined in:
- lib/cure/strategy/split_strategy.rb
Instance Attribute Summary collapse
-
#params ⇒ SplitStrategyParams
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) ⇒ SplitStrategy
constructor
A new instance of SplitStrategy.
Methods inherited from BaseStrategy
Methods included from History
#history, #reset_history, #retrieve_history, #store_history
Constructor Details
#initialize(options) ⇒ SplitStrategy
Returns a new instance of SplitStrategy.
12 13 14 |
# File 'lib/cure/strategy/split_strategy.rb', line 12 def initialize() super(SplitStrategyParams.new()) end |
Instance Attribute Details
#params ⇒ SplitStrategyParams
Additional details needed to make substitution.
10 11 12 |
# File 'lib/cure/strategy/split_strategy.rb', line 10 def params @params end |
Instance Method Details
#_describe ⇒ Object
37 38 39 40 |
# File 'lib/cure/strategy/split_strategy.rb', line 37 def _describe "Splitting on '#{@params.token}', at index #{@params.index}) " \ "[Note: If the value does not include '#{@params.token}', no substitution is made.]" end |
#_replace_value(source_value, generated_value) ⇒ String
27 28 29 30 31 32 33 34 35 |
# File 'lib/cure/strategy/split_strategy.rb', line 27 def _replace_value(source_value, generated_value) split_token = @params.token return unless source_value.include?(split_token) result_arr = source_value.split(split_token) result_arr[@params.index] = generated_value if value?(result_arr[@params.index]) result_arr.join(split_token) end |
#_retrieve_value(source_value) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/cure/strategy/split_strategy.rb', line 17 def _retrieve_value(source_value) return unless source_value.include?(@params.token) result_arr = source_value.split(@params.token) result_arr[@params.index] end |