Sha256: d509905aba14cd99f8eede15a07d7b06b78ea481c1fca28a59d6807e3cd9c972

Contents?: true

Size: 752 Bytes

Versions: 5

Compression:

Stored size: 752 Bytes

Contents

module Tufy
  module Fields
    module Account
      class BuildOutstandingBalanceField < BuildField
        expects :raw_data
        promises :transformed_data

        executed do |ctx|
          ctx.transformed_data =
            ctx.transformed_data +
            transform(ctx).upcase
        end

        private

        def self.transform(ctx)
          raw_data = ctx.raw_data

          outstanding_balance = raw_data[:outstanding_balance].to_i
          outstanding_balance = outstanding_balance < 0 ? 0 : outstanding_balance

          BuildAccountSegment::Constants::OUTSTANDING_BALANCE_TAG +
            FormatStrings::F2TS % outstanding_balance.to_s.size +
              outstanding_balance.to_s
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tufy-0.0.13 lib/tufy/fields/account/build_outstanding_balance_field.rb
tufy-0.0.12 lib/tufy/fields/account/build_outstanding_balance_field.rb
tufy-0.0.11 lib/tufy/fields/account/build_outstanding_balance_field.rb
tufy-0.0.10 lib/tufy/fields/account/build_outstanding_balance_field.rb
tufy-0.0.9 lib/tufy/fields/account/build_outstanding_balance_field.rb