From 6fc6b1ef2c2bc623392164309f1841374882899a Mon Sep 17 00:00:00 2001 From: martinahansen Date: Thu, 1 Nov 2012 14:18:11 +0000 Subject: [PATCH] added get_entry method to biopieces.rb git-svn-id: http://biopieces.googlecode.com/svn/trunk@1981 74ccb610-7750-0410-82ae-013aeee3265d --- code_ruby/lib/maasha/biopieces.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/code_ruby/lib/maasha/biopieces.rb b/code_ruby/lib/maasha/biopieces.rb index 8d030df..bd85afb 100644 --- a/code_ruby/lib/maasha/biopieces.rb +++ b/code_ruby/lib/maasha/biopieces.rb @@ -123,6 +123,16 @@ class Biopieces # Method to parse and yield a Biopiece record from _ios_. def each_record + while record = get_entry + yield record + end + + self # conventionally + end + + alias :each :each_record + + def get_entry record = {} @ios.each_line do |line| @@ -130,19 +140,16 @@ class Biopieces when /^([^:]+): (.*)$/ record[$1.to_sym] = $2 when /^---$/ - yield record unless record.empty? - record = {} + break else raise BiopiecesError, "Bad record format: #{line}" end end - yield record unless record.empty? - - self # conventionally + return record unless record.empty? end - alias :each :each_record + alias :get_record :each_entry private -- 2.39.2