Class: LEWT::LEWTBook

Inherits:
Array
  • Object
show all
Defined in:
lib/lewt_book.rb

Overview

The LEWTBook is used by extractors as a generic data structure to adhere to when returning there results. It follows a basic *general ledger* format without the double-entry book keeping.

Usage:

lewtbook = LEWTBook.new() lewtbook.add_row( LEWTLedger.new( params, … ) )

Instance Method Summary collapse

Instance Method Details

#push(element) ⇒ Object

adds a row to this element as per array.push. only accespts LEWTLedger objects as entries.

element [LEWTLedger]

An initialised LEWTLedger object containing your data.



20
21
22
23
24
25
26
# File 'lib/lewt_book.rb', line 20

def push ( element )
  if element.kind_of?(LEWT::LEWTLedger)
    self.class.superclass.instance_method(:push).bind(self).call element
  else
    raise TypeError, "Class #{self.class.name} only accepts LEWT::LEWTLedger objects as its contents"
  end
end