OSDN Git Service

refactored
authornomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 18:25:48 +0000 (03:25 +0900)
committernomeu <nomeu@nomeu.org>
Sat, 12 Jun 2010 18:25:48 +0000 (03:25 +0900)
bin/read-upl.rb
lib/scrap.rb

index 94e428b..6ebbb27 100644 (file)
@@ -4,17 +4,7 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
 require 'scrap'
 
 location = ARGV.shift || 'mmd'
-
-case location
-when 'mmd'
-  scrap = Scrap_mmd.new
-when 'mmdfile'
-  scrap = Scrap_mmdfile.new
-when 'mmdacc1'
-  scrap = Scrap_mmdacc1.new
-when 'mmdacc2'
-  scrap = Scrap_mmdacc2.new
-end
+scrap = Scrap.find_by_location(location)
 
 ent = "/Volumes/uploader/src/#{location}/index.html"
 open(ent) do |f|
index 05f8967..f8a3550 100644 (file)
@@ -2,6 +2,7 @@
 require 'nkf'
 
 class Scrap
+
   def match(line)
     @md = @row_re.match(line)
   end
@@ -70,3 +71,16 @@ class Scrap_mmdacc2 < Scrap
     [ name, encode(comment), size, encode(date) ]
   end
 end
+
+def Scrap.find_by_location(location)
+  case location
+  when 'mmd'
+    scrap = Scrap_mmd.new
+  when 'mmdfile'
+    scrap = Scrap_mmdfile.new
+  when 'mmdacc1'
+    scrap = Scrap_mmdacc1.new
+  when 'mmdacc2'
+    scrap = Scrap_mmdacc2.new
+  end
+end