### Install Riif Ruby Gem Source: https://github.com/linjunpop/riif/blob/master/README.md Instructions for adding the Riif gem to a Ruby project's Gemfile for dependency management or installing it directly via the command line for standalone use. ```Ruby gem 'riif' ``` ```Shell $ bundle ``` ```Shell $ gem install riif ``` -------------------------------- ### Example Output of Generated IIF File Source: https://github.com/linjunpop/riif/blob/master/README.md This snippet shows the raw IIF file content generated by the Riif DSL, demonstrating the header lines for TRNS and SPL records, followed by the actual data rows formatted according to the IIF specification. ```APIDOC !TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 DUEDATE TERMS PAID SHIPDATE !SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE REIMBEXP EXTRA !ENDTRNS TRNS 123 INVOICE 8/31/1988 Accounts Receivable Customer 20 1 N N Baker Customer SPL 777 INVOICE 8/31/1988 Income Account -20 N -2 10 Sales Item N SPL 888 ENDTRNS ``` -------------------------------- ### Riif DSL Template for Rails IIF Generation Source: https://github.com/linjunpop/riif/blob/master/README.md Example of a Riif DSL template (`.iif.riif` file) used within a Rails application. It defines a TRNS (transaction) block with a main row and multiple SPL (split) rows, specifying various IIF fields like transaction ID, type, date, account, amount, and item details. ```Ruby iif.trns do row do trnsid 123 trnstype 'INVOICE' date '8/31/1988' accnt 'Accounts Receivable' name 'Customer' amount 20 docnum invoice.id clear 'N' toprint 'N' addr1 'Baker' addr2 'Customer' end spl do row do splid '777' trnstype 'INVOICE' date '8/31/1988' accnt 'Income Account' amount '-20' clear 'N' qnty '-2' price 10 invitem 'Sales Item' taxable 'N' end end spl do row do splid '888' end end end ``` -------------------------------- ### Rails Controller Integration for IIF Export Source: https://github.com/linjunpop/riif/blob/master/README.md Demonstrates how to configure a Rails controller to respond to an IIF format request. It uses `respond_to` to render an IIF file from a string, specifying the filename for download. ```Ruby class InvoicesController < ApplicationController def show respond_to do |format| format.iif { render iif: render_to_string, filename: 'batman'} format.html end end end ``` -------------------------------- ### Standalone Riif DSL Usage for IIF Generation Source: https://github.com/linjunpop/riif/blob/master/README.md Illustrates how to use the Riif DSL directly without Rails, creating an IIF object and defining transaction and split rows programmatically. This snippet shows two ways: one without block arguments and another passing block arguments for explicit object references. ```Ruby Riif::IIF.new do trns do row do trnsid 123 trnstype 'INVOICE' date '8/31/1988' accnt 'Accounts Receivable' name 'Customer' amount 20 docnum 1 clear 'N' toprint 'N' addr1 'Baker' addr2 'Customer' end spl do row do splid '777' trnstype 'INVOICE' date '8/31/1988' accnt 'Income Account' amount '-20' clear 'N' qnty '-2' price 10 invitem 'Sales Item' taxable 'N' end end spl do row do splid '888' end end end end ``` ```Ruby Riif::IIF.new do |riif| riif.trns do |trns| trns.row do |row| row.trnsid 123 row.trnstype 'INVOICE' row.date '8/31/1988' row.accnt 'Accounts Receivable' row.name 'Customer' end end end ``` -------------------------------- ### Vim Editor Configuration for Riif Files Source: https://github.com/linjunpop/riif/blob/master/README.md VimL command to automatically set the filetype to 'ruby' for files with the '.riif' extension. This enables Ruby syntax highlighting and other language-specific features in Vim when editing Riif DSL templates. ```VimL au BufWinEnter,BufRead,BufNewFile *.riif set filetype=ruby ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.