[logaling-commit] logaling/logaling-command [master] Extract TermJsonRenderer#first_line?, last_line?

Back to archive index

null+****@clear***** null+****@clear*****
Thu Jun 28 12:01:59 JST 2012


SHIMADA Koji	2012-06-02 17:48:20 +0900 (Sat, 02 Jun 2012)

  New Revision: 4402b278ca52af68173e7183fc276e5e7813edeb
  https://github.com/logaling/logaling-command/commit/4402b278ca52af68173e7183fc276e5e7813edeb

  Merged 7228757: Merge pull request #60 from logaling/refactor-structure

  Log:
    Extract TermJsonRenderer#first_line?, last_line?

  Modified files:
    lib/logaling/command/renderers.rb

  Modified: lib/logaling/command/renderers.rb (+10 -3)
===================================================================
--- lib/logaling/command/renderers.rb    2012-06-02 17:35:46 +0900 (0c6cac5)
+++ lib/logaling/command/renderers.rb    2012-06-02 17:48:20 +0900 (5714fa5)
@@ -72,15 +72,22 @@ module Logaling::Command
       end
 
       def render
-        puts("[") if @index == 0
-        puts(",") if @index > 0
+        first_line? ? puts("[") : puts(",")
         record = {
           :source => source_term, :target => target_term, :note => note,
           :source_language => @config.source_language,
           :target_language => @config.target_language
         }
         print JSON.pretty_generate(record)
-        puts("\n]") if @index == @last_index-1
+        puts("\n]") if last_line?
+      end
+
+      private
+      def first_line?
+        @index == 0
+      end
+      def last_line?
+        @index == @last_index-1
       end
     end
   end
-------------- next part --------------
An HTML attachment was scrubbed...
下載 



More information about the logaling-commit mailing list
Back to archive index