Class: Remi::Transform::Nvl
- Inherits:
-
Remi::Transform
- Object
- Remi::Transform
- Remi::Transform::Nvl
- Defined in:
- lib/remi/transform.rb
Overview
Public: (Next-Value-Lookup) transform used to find the first non-blank value in a list.
default - What to use if all values are blank (default: '').
Examples:
Nvl.new.to_proc.call(nil,'','a','b') # => "a"
Instance Attribute Summary
Attributes inherited from Remi::Transform
#multi_args, #source_metadata, #target_metadata
Instance Method Summary collapse
-
#initialize(default = '', *args, **kargs, &block) ⇒ Nvl
constructor
A new instance of Nvl.
- #transform(row) ⇒ Object
Methods inherited from Remi::Transform
Constructor Details
#initialize(default = '', *args, **kargs, &block) ⇒ Nvl
Returns a new instance of Nvl.
186 187 188 189 190 |
# File 'lib/remi/transform.rb', line 186 def initialize(default='', *args, **kargs, &block) super @multi_args = true @default = default end |
Instance Method Details
#transform(row) ⇒ Object
192 193 194 195 |
# File 'lib/remi/transform.rb', line 192 def transform(row) row = SourceToTargetMap::Row[row] row.each_source.find(->() { [nil, @default] }) { |key, value| !value.blank? }[1] end |