Module: OFX
- Defined in:
- lib/ofx_kit.rb,
lib/ofx_kit/parser.rb,
lib/ofx_kit/balance.rb,
lib/ofx_kit/version.rb,
lib/ofx_kit/base/entity.rb,
lib/ofx_kit/transaction.rb,
lib/ofx_kit/bank_account.rb,
lib/ofx_kit/base/account.rb,
lib/ofx_kit/base/builder.rb,
lib/ofx_kit/errors/error.rb,
lib/ofx_kit/base/document.rb,
lib/ofx_kit/bank_statement.rb,
lib/ofx_kit/base/statement.rb,
lib/ofx_kit/tokenizer/base.rb,
lib/ofx_kit/tokenizer/ofx1.rb,
lib/ofx_kit/tokenizer/ofx2.rb,
lib/ofx_kit/configuration/core.rb,
lib/ofx_kit/errors/parse_error.rb,
lib/ofx_kit/credit_card_account.rb,
lib/ofx_kit/credit_card_statement.rb,
lib/ofx_kit/errors/encoding_error.rb,
lib/ofx_kit/transaction_collection.rb,
lib/ofx_kit/configuration/date_parser.rb,
lib/ofx_kit/errors/invalid_body_error.rb,
lib/generators/ofx_kit/eject_generator.rb,
lib/ofx_kit/errors/configuration_error.rb,
lib/ofx_kit/configuration/section_proxy.rb,
lib/ofx_kit/errors/invalid_header_error.rb,
lib/ofx_kit/configuration/mapping_applicator.rb,
lib/ofx_kit/errors/multiple_statements_error.rb,
lib/ofx_kit/errors/unsupported_version_error.rb
Overview
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
Defined Under Namespace
Modules: Base, Errors, Generators, Tokenizer Classes: Balance, BankAccount, BankStatement, Configuration, CreditCardAccount, CreditCardStatement, Parser, Transaction, TransactionCollection
Constant Summary collapse
- VERSION =
Current gem version (String).
'1.0.0'
Class Method Summary collapse
-
.config ⇒ Object
Returns the shared configuration instance (lazy-initialized).
-
.configure ⇒ Object
Yields the current Configuration instance for customization.
-
.new(resource) ⇒ Object
Parses an OFX file or IO object and returns a Parser instance.
-
.reset_config! ⇒ Object
Resets the configuration to its default state.
Class Method Details
.config ⇒ Object
Returns the shared configuration instance (lazy-initialized).
92 93 94 |
# File 'lib/ofx_kit.rb', line 92 def config @config ||= Configuration.new end |
.configure ⇒ Object
Yields the current Configuration instance for customization.
:yields: config
Raises Errors::ConfigurationError if the block raises any error.
82 83 84 85 86 87 88 |
# File 'lib/ofx_kit.rb', line 82 def configure yield config rescue Errors::ConfigurationError raise rescue StandardError => e raise Errors::ConfigurationError, e. end |
.new(resource) ⇒ Object
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
72 73 74 |
# File 'lib/ofx_kit.rb', line 72 def new(resource, &) Parser.new(resource, &) end |
.reset_config! ⇒ Object
Resets the configuration to its default state. Useful in tests to restore default field mappings between examples.
99 100 101 |
# File 'lib/ofx_kit.rb', line 99 def reset_config! @config = nil end |