This commit is contained in:
Albert Yi
2018-06-05 13:23:30 -07:00
parent c1725f6dc0
commit 2ec9aad320
2 changed files with 23 additions and 0 deletions

View File

@@ -1,3 +1,15 @@
class PixivUgoiraFrameData < ApplicationRecord
serialize :data
before_validation :normalize_data, on: :create
def normalize_data
return if data.nil?
if data[0]["delay_msec"]
self.data = data.map.with_index do |datum, i|
filename = "%06d.jpg" % [i + 1]
{"delay" => datum["delay_msec"], "file" => filename}
end
end
end
end