class Phantom::SVG::Parser::JSONAnimationReader

AnimationReader for JSON.

Private Instance Methods

read_frame_infos(value) click to toggle source

Read frame informations

# File lib/phantom/parser/json_animation_reader.rb, line 27
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
read_parameter(path) click to toggle source

Read parameter from animation information file.

# File lib/phantom/parser/json_animation_reader.rb, line 14
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