]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_ruby/lib/maasha/biopieces.rb
added get_entry method to biopieces.rb
[biopieces.git] / 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