Class: Remi::Transform::Truncate

Inherits:
Remi::Transform show all
Defined in:
lib/remi/transform.rb

Overview

Public: Transform used to truncate values in a vector.

len - The maximum length of the string.

Examples:

Truncate.new(3).to_proc.call('1234') # => "123"

Instance Attribute Summary

Attributes inherited from Remi::Transform

#multi_args, #source_metadata, #target_metadata

Instance Method Summary collapse

Methods inherited from Remi::Transform

#call, #to_proc

Constructor Details

#initialize(len, *args, **kargs, &block) ⇒ Truncate

Returns a new instance of Truncate.



114
115
116
117
# File 'lib/remi/transform.rb', line 114

def initialize(len, *args, **kargs, &block)
  super
  @len = len
end

Instance Method Details

#transform(value) ⇒ Object



119
120
121
# File 'lib/remi/transform.rb', line 119

def transform(value)
  (value || '').slice(0,@len)
end