]> git.donarmstrong.com Git - biopieces.git/commitdiff
added get_entry method to biopieces.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 1 Nov 2012 14:18:11 +0000 (14:18 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 1 Nov 2012 14:18:11 +0000 (14:18 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1981 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/biopieces.rb

index 8d030dfa80d08edc0aa32cac82e497196b3d51de..bd85afb0f4a86c02eaaa8a0dc07324489d8ed6f0 100644 (file)
@@ -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