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 85 def config @config ||= Configuration.new end
Returns the shared configuration instance (lazy-initialized).
Source
# File lib/ofx_kit.rb, line 75 def configure yield config rescue Error::InvalidConfiguration raise rescue StandardError => e raise Error::InvalidConfiguration, e.message end
Yields the current Configuration instance for customization.
Raises OFX::Error::InvalidConfiguration if the block raises any error.
Source
# File lib/ofx_kit.rb, line 65 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 92 def reset_config! @config = nil end
Resets the configuration to its default state. Useful in tests to restore default field mappings between examples.