Code Monkey home page Code Monkey logo

rbktoblzcheck's Introduction

Ruby KtoBlzCheck
================

rbKtoBlzCheck is a small Ruby extension for Linux (written in C) that provides
an interface for libktoblzcheck, a library to check German account numbers and
bank codes. See http://ktoblzcheck.sourceforge.net for details.

Install instructions
--------------------

Just install the gem with the following command:

  $ gem install ktoblzcheck


Common errors:
--------------

* ruby extconf.rb fails with 
  "Couldn't find header file..." or
  "Couldn't find link library..."

  => Make sure the ktoblzcheck library and header files are correctly installed.
  => Consult the file mkmf.log for details of build time checks
  => Hint: If you've build and installed the ktoblzcheck library from source, make sure
     the install locations of the library files are listed in /etc/ld.so.conf and you've run 
     `ldconfig`

* compile errors

  Nothing to mention here: the code compiles without warning on Linux 2.6.7,
  glibc-2.3.2, gcc version 3.3.4 (Debian 1:3.3.4-7) with ruby 1.8.2
  (2004-07-29) [i386-linux].
  

Dependencies:
-------------

- Ruby >= 1.8
- libktoblzcheck (obviously :)

The ktoblzcheck package can be downloaded from
http://ktoblzcheck.sourceforge.net/ as source distribution tar-ball or RPM.

Debian has a package named 'libktoblzcheck1-dev' available in testing and
unstable, simply apt-get install it.



Other platforms:
----------------

As I have no suitable non-Linux systems to mess around with, I have no idea
whether this Ruby extension compiles and/or runs correctly on other platforms.

I guess, there should be no problems on BSDish systems. While the C-code should
be quiet portable, I'm not sure if linking works correctly on Microsoft (R)
Windows (R).

Comments on problems with OSes other than Linux are always welcome.

License:
--------

BSD-style, see LICENSE

This project is based on the work of Sascha Loetz (blog.cadego.de, info@cadego(dot)de).

Ruby Interface:
===============

Example:
-----------------------------------------------------------------------
require 'ktoblzcheck'

$bc="20030700"
$an="0"

puts "Testing Bank Code: #{$bc} / Account No. #{$an}"

KtoBlzCheck.new do |kbc|
  name,location=kbc.find($bc)
  if name
    puts "Bank found! #{name} located in #{location}"
  else
    puts "Bank not found!"
  end
  case kbc.check($bc,$an)
    when KtoBlzCheck::ERROR
      puts "Failed, bank code and account number don't match"
    when KtoBlzCheck::OK
      puts "Success, valid combination of bank code and account number"
    when KtoBlzCheck::UNKNOWN
      puts "Unknown."
    when KtoBlzCheck::BANK_NOT_KNOWN
      puts "Unknown bank code"
    else
      puts "Never reached :)"
  end
end
-----------------------------------------------------------------------

For more code examples refer to the rbkbc program and the test-*.rb files
provided with this distribution.


Interface documentation:
========================

-----------------------------------------------------------------------
KtoBlzCheck.new [ |block| ] -> obj
KtoBlzCheck.new(datafilepath) [ |block| ] -> obj
-----------------------------------------------------------------------

Constructs a new KtoBlzCheck object, returns it or passes it to an 
optional code block. If no block is provided, the user must call 
KtoBlzCheck#close to ensure that all resources are freed
after usage.

If a parameter is passed to new it is interpreted as the path to the
data file to be used by libktoblzcheck. When the parameter is omitted,
the default file of libktoblzcheck is used 
(usually /usr/[local/]share/[lib]ktoblzcheck[*]/bankdata.txt).

A nil value passed as parameter is ignored.
-----------------------------------------------------------------------


-----------------------------------------------------------------------
KtoBlzCheck#close
-----------------------------------------------------------------------
Closes the KtoBlzCheck object's handle for libktoblzcheck. Must be 
called to prevent resource leaks if KtoBlzCheck#new is not used with 
block syntax.
-----------------------------------------------------------------------


-----------------------------------------------------------------------
KtoBlzCheck#num_records -> aFixnum
-----------------------------------------------------------------------
Returns the number of entries in the currently used data file for
libktoblzcheck.
-----------------------------------------------------------------------


-----------------------------------------------------------------------
KtoBlzCheck#check(bank_code, account_no) -> aFixnum
-----------------------------------------------------------------------
Checks if bank_code and account_no form a valid combination. The 
returned Fixnum indicates the result. The following constants can be
used test the result:

KtoBlzCheck::OK -> valid combination of bank code and account number
KtoBlzCheck::ERROR -> !OK
KtoBlzCheck::UNKNOWN -> no verification possible for unknown reason
KtoBlzCheck::BANK_NOT_KNOWN -> bank code not known

If bank_code and account_no are not of type String a TypeError is
raised.
-----------------------------------------------------------------------


-----------------------------------------------------------------------
KtoBlzCheck#find(bank_code) -> anArray
-----------------------------------------------------------------------
Looks up bank name and bank location (city) for the bank identified
by bank_code.

Returns an array with the bank's name (index 0) and the bank's location 
(index 1). The returned array is empty if no bank is found for the given 
bank code.
-----------------------------------------------------------------------

rbktoblzcheck's People

Contributors

krudolph avatar

Watchers

Antony Ingram avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.