Class: Phantom::SVG::Parser::AbstractAnimationReader

Inherits:
Object
  • Object
show all
Defined in:
lib/phantom/parser/abstract_animation_reader.rb

Overview

AnimationReader base.

Direct Known Subclasses

JSONAnimationReader, XMLAnimationReader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ AbstractAnimationReader

Construct AbstractAnimationReader object.



11
12
13
14
# File 'lib/phantom/parser/abstract_animation_reader.rb', line 11

def initialize(path = nil)
  reset
  read(path) unless path.nil?
end

Instance Attribute Details

#framesObject

Returns the value of attribute frames.



8
9
10
# File 'lib/phantom/parser/abstract_animation_reader.rb', line 8

def frames
  @frames
end

#loopsObject

Returns the value of attribute loops.



8
9
10
# File 'lib/phantom/parser/abstract_animation_reader.rb', line 8

def loops
  @loops
end

#skip_firstObject

Returns the value of attribute skip_first.



8
9
10
# File 'lib/phantom/parser/abstract_animation_reader.rb', line 8

def skip_first
  @skip_first
end

Instance Method Details

#read(path, do_reset = true) ⇒ Object

Read and create frames from animation information file. Return array of Phantom::SVG::Frame.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/phantom/parser/abstract_animation_reader.rb', line 18

def read(path, do_reset = true)
  reset if do_reset

  # Read parameter from spec file.
  read_parameter(path)

  # Change current directory to animation information file's directory.
  old_dir = Dir.pwd
  Dir.chdir(File.dirname(path))

  # Create frames from animation information file parameter.
  create_frames

  # Change current directory to default.
  Dir.chdir(old_dir)

  # Return frames.
  @frames
end