Sha256: bf4f50e1b7f3638ba4deeb9cfe65cd8f10f68639a35fbe9951d22587a6bd28f6
Contents?: true
Size: 1.18 KB
Versions: 17
Compression:
Stored size: 1.18 KB
Contents
require 'json' require_relative '../frame.rb' require_relative 'abstract_animation_reader.rb' module Phantom module SVG module Parser # AnimationReader for JSON. class JSONAnimationReader < AbstractAnimationReader private # Read parameter from animation information file. def read_parameter(path) open(path) do |file| JSON.load(file).each do |key, val| case key when 'frames' then read_frame_infos(val) when 'delays' then val.each { |delay| add_delay(delay) } else set_parameter(key, val) end end end end # Read frame informations def read_frame_infos(value) value.each do |frame_info| if frame_info.instance_of?(Hash) frame_info.each do |name, delay| add_frame_info(name, delay) end else add_frame_info(frame_info) end end end end # class JSONAnimationReader < AbstractAnimationReader end # module Parser end # module SVG end # module Phantom
Version data entries
17 entries across 17 versions & 1 rubygems