Sha256: a5c29ac7fbc42498be9dffcc82faa7a499d72fd7a77a79cac52aa9affb04c700

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

# typed: strict

module LedgerGen
  class Posting
    extend T::Sig

    sig {void}
    def initialize
      @account = T.let('', String)
      @amount = T.let(0, Numeric)
    end

    sig { params(account: String).returns(String) }
    def account(account)
      @account = account
    end

    sig { params(amount: Numeric).returns(Numeric) }
    def amount(amount)
      @amount = amount
    end

    sig {returns(String)}
    def to_s
      "#{@account}  #{amount_string}"
    end

    sig {returns(String)}
    def amount_string
      if @amount.nil?
        ''
      else
        sprintf('$%0.2f', @amount)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_gen-1.0.0 lib/ledger_gen/posting.rb