Class: Remi::Transform::Postfix

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

Overview

Public: Transform used to postfix values in a vector.

postfix - The string postfix. if_blank - String value to substitute if the value is blank (default: ”).

Examples:

Postfix.new('A').to_proc.call('123') # => "123A"

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(postfix, *args, if_blank: '', **kargs, &block) ⇒ Postfix

Returns a new instance of Postfix.



90
91
92
93
94
# File 'lib/remi/transform.rb', line 90

def initialize(postfix, *args, if_blank: '', **kargs, &block)
  super
  @postfix   = postfix
  @if_blank = if_blank
end

Instance Method Details

#transform(value) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/remi/transform.rb', line 96

def transform(value)
  if value.blank?
    @if_blank
  else
    "#{value}#{@postfix}"
  end
end