Class: DataMaps::Converter::Prefix
- Inherits:
-
Base
- Object
- Executable
- Base
- DataMaps::Converter::Prefix
- Defined in:
- lib/data_maps/converter/affixes.rb
Overview
Adds a prefix to the given data
Instance Attribute Summary
Attributes inherited from Executable
Instance Method Summary collapse
-
#execute(data) ⇒ Object
The execute method to adds a prefix to the given data.
Methods inherited from Executable
#initialize, valid_collection?
Constructor Details
This class inherits a constructor from DataMaps::Executable
Instance Method Details
#execute(data) ⇒ Object
The execute method to adds a prefix to the given data
10 11 12 13 14 15 16 |
# File 'lib/data_maps/converter/affixes.rb', line 10 def execute(data) case data when Array then data.map{ |v| "#{option}#{v}" } when Hash then Hash[data.map{ |k,v| [k,"#{option}#{v}"] }] else "#{option}#{data}" end end |