From 3698154c2e8dd6bfc3b5209dcc9f9e01d5406c23 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 8 Aug 2013 23:50:34 -0400 Subject: [PATCH] Book: add start_date and end_date --- lib/gnucash/book.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/gnucash/book.rb b/lib/gnucash/book.rb index 6c6a6f2..ecc05c4 100644 --- a/lib/gnucash/book.rb +++ b/lib/gnucash/book.rb @@ -5,6 +5,8 @@ module Gnucash class Book attr_accessor :accounts attr_accessor :transactions + attr_accessor :start_date + attr_accessor :end_date def initialize(fname) @ng = Nokogiri.XML(Zlib::GzipReader.open(fname).read) @@ -31,8 +33,13 @@ module Gnucash end def build_transactions + @start_date = nil + @end_date = nil @transactions = @book_node.xpath('gnc:transaction').map do |txn_node| - Transaction.new(self, txn_node) + Transaction.new(self, txn_node).tap do |txn| + @start_date = txn.date if @start_date.nil? or txn.date < @start_date + @end_date = txn.date if @end_date.nil? or txn.date > @end_date + end end end