Sha256: 3a5b7351383ea538962744753882b41da580f958cd04e86e6e7242e7436e094f

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

module AplFieldPadder

  TYPE_VAL_NUM_SLOTS = 4
  BU_ID_NUM_SLOTS = 6

  PADDING_CHAR = '*'

  def get_padded_type type_val
    return get_padded_value(type_val, TYPE_VAL_NUM_SLOTS)
  end

  def get_padded_bu bu_id_val
    return get_padded_value(bu_id_val, BU_ID_NUM_SLOTS)
  end

  private

  def get_padded_value(field_val, num_slot_for_field)
    default_string =  PADDING_CHAR*num_slot_for_field
    return default_string if field_val.blank?

    padded_field_val = default_string.sub(PADDING_CHAR*field_val.size, field_val)
    padded_field_val
  end

end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
apl-library-0.0.90 lib/apl-library/apl_field_padder.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/lib/apl-library/apl_field_padder.rb