OSDN Git Service

t#31484:validate z
[pettanr/pettanr.git] / app / models / panel.rb
index 8958978..e343bfa 100644 (file)
@@ -258,33 +258,34 @@ class Panel < ActiveRecord::Base
     }.flatten
   end
   
-  def self.validate_t ary
-    i = 0
-    ary.compact.sort.each do |t|
-      break false unless t == i
+  def self.validate_serial ary, offset = 0
+    i = offset
+    ary.compact.sort.each do |n|
+      break false unless n == i
       i += 1
     end
-    ary.compact.size == i
+    ary.compact.size == i - offset
   end
   
-  def self.validate_element_t elements, name
-    Panel.validate_t(Panel.collect_element_value(elements, name))
+  def self.validate_element_serial elements, name, offset = 0
+    Panel.validate_serial(Panel.collect_element_value(elements, name), offset)
   end
   
-  def self.validate_elements_t c
+  def self.validate_elements_serial c
     c.map {|conf|
-      Panel.validate_element_t(conf[:elements], conf[:name]) ? nil : false
+      Panel.validate_element_serial(conf[:elements], conf[:name], conf[:offset]) ? nil : false
     }.compact.empty?
   end
   
-  def validate_t_list
+  def validate_serial_list
     [
-      {:elements => [self.panel_pictures, self.speech_balloons, self.ground_colors, self.ground_pictures], :name => :t}
+      {:elements => [self.panel_pictures, self.speech_balloons, self.ground_colors, self.ground_pictures], :name => :t, :offset => 0}, 
+      {:elements => [self.panel_pictures, self.speech_balloons, self.ground_colors, self.ground_pictures], :name => :z, :offset => 1}
     ]
   end
   def validate_child
 #    r1 = Panel.validate_elements_id validate_id_list
-    Panel.validate_elements_t validate_t_list
+    Panel.validate_elements_serial validate_serial_list
   end
   
   def store attr, au