module OFX
Top-level namespace for the ofx_kit gem. Provides module-level access to the shared Configuration instance and a configure block for customizing field mappings and XML tags.
Example: Configure custom field mappings
OFX.configure do |config| config.transaction.map 'MYFIELD', to: :my_attribute end
Constants
- VERSION
-
Current gem version (String).
Public Class Methods
Source
# File lib/ofx_kit.rb, line 92 def config @config ||= Configuration.new end
Returns the shared configuration instance (lazy-initialized).
Source
# File lib/ofx_kit.rb, line 82 def configure yield config rescue Errors::ConfigurationError raise rescue StandardError => e raise Errors::ConfigurationError, e.message end
Yields the current Configuration instance for customization.
Raises Errors::ConfigurationError if the block raises any error.
Source
# File lib/ofx_kit.rb, line 72 def new(resource, &) Parser.new(resource, &) end
Parses an OFX file or IO object and returns a Parser instance. This is the primary entry point for the gem. resource is a file path (String) or IO object containing OFX data.
Example: Parse a file path
ofx = OFX.new("statement.ofx") ofx.account #=> OFX::BankAccount ofx.transactions #=> OFX::TransactionCollection
Example: Parse an IO object
ofx = OFX.new(File.open("statement.ofx"))
Example: Block form
OFX.new("statement.ofx") do |ofx| puts ofx.balance end
Source
# File lib/ofx_kit.rb, line 99 def reset_config! @config = nil end
Resets the configuration to its default state. Useful in tests to restore default field mappings between examples.