Class: ETL::Transform::TrimTransform
- Defined in:
- lib/etl/transform/trim_transform.rb
Overview
Transform to trim string
Instance Attribute Summary
Attributes inherited from Transform
#configuration, #control, #name
Instance Method Summary collapse
-
#initialize(control, name, configuration = {}) ⇒ TrimTransform
constructor
Configuration options: *
:type
: :left, :right or :both. -
#transform(name, value, row) ⇒ Object
Transform the value.
Methods inherited from Transform
Constructor Details
#initialize(control, name, configuration = {}) ⇒ TrimTransform
Configuration options:
-
:type
: :left, :right or :both. Default is :both
7 8 9 10 |
# File 'lib/etl/transform/trim_transform.rb', line 7 def initialize(control, name, configuration={}) super @type = (configuration[:type] || :both).to_sym end |
Instance Method Details
#transform(name, value, row) ⇒ Object
Transform the value
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/etl/transform/trim_transform.rb', line 12 def transform(name, value, row) case @type when :left value.lstrip when :right value.rstrip when :both value.strip else raise "Trim type, if specified, must be :left, :right or :both" end end |