Sha256: 78f2127fcd3e043c897db63f3a9077531d731b8d6e2f924647eb5ee7b43a2d50

Contents?: true

Size: 523 Bytes

Versions: 1

Compression:

Stored size: 523 Bytes

Contents

module LedgerGen
  class Journal
    def self.build
      journal = new
  
      yield journal

      return journal
    end
    
    def initialize
      @transactions = []
    end

    def transaction
      txn = Transaction.new
      @transactions << txn

      yield txn
    end

    def to_s
      @transactions.map(&:to_s).join("\n\n") + "\n"
    end

    def pretty_print
      IO.popen("ledger -f - print", mode='r+') do |io|
        io.write to_s
        io.close_write
        io.read
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ledger_gen-0.1.0 lib/ledger_gen/journal.rb