Use symbols instead of constants for tween modes.
authorTilman Sauerbeck <tilman@code-monkey.de>
Sat, 2 Apr 2005 23:20:32 +0000 (23:20 +0000)
committerTilman Sauerbeck <tilman@code-monkey.de>
Sat, 2 Apr 2005 23:20:32 +0000 (23:20 +0000)
ChangeLog
lib/redact/program.rb

index 3e2af85cbffaa4d54089cdeeb34b16099c444627..4e7302d6c641f8a67727e970786db9a73a76db02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,5 @@
 --
-$Id: ChangeLog 22 2005-04-02 22:29:50Z tilman $
+$Id: ChangeLog 23 2005-04-02 23:20:32Z tilman $
 ++
 
 2005-04-03 Tilman Sauerbeck (tilman at code-monkey de)
@@ -9,6 +9,8 @@ $Id: ChangeLog 22 2005-04-02 22:29:50Z tilman $
         * lib/redact/part.rb: Use symbols instead of constants for text
           effects
         * lib/redact/part.rb: Code cleanup
+        * lib/redact/program.rb: Use symbols instead of constants for
+          tween modes
 
 2005-04-02 Tilman Sauerbeck (tilman at code-monkey de)
         * lib/redact/part.rb: Made 'step' and 'aspect' parameters
index 78f2ca960a3904912650ea32daa252979e99b9ad..d6038d9646b82d17c75a499fa3e361d8d87884fa 100644 (file)
@@ -1,5 +1,5 @@
 #--
-# $Id: program.rb 1 2005-03-26 01:32:38Z tilman $
+# $Id: program.rb 23 2005-04-02 23:20:32Z tilman $
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
@@ -73,11 +73,6 @@ module Redact
        end
 
        class SetStateProgram < Program
-               MODE_LINEAR = 1
-               MODE_SINUSOIDAL = 2
-               MODE_ACCELERATE = 3
-               MODE_DECELERATE = 4
-
                attr_reader :targets
                attr_accessor :state, :value, :mode, :time
 
@@ -87,16 +82,25 @@ module Redact
                        @type = TYPE_SET_STATE
                        @state = "default"
                        @value = 0.0
-                       @mode = MODE_LINEAR
+                       @mode = :linear
                        @time = 0.0
                        @targets = ProgramArgs.new(collection)
                end
 
                def to_eet_properties
+                       mode = case @mode
+                       when :linear: 1
+                       when :sinusoidal: 2
+                       when :accelerate: 3
+                       when :decelerate: 4
+                       else
+                               raise(RedactError, "invalid mode - #{@mode}")
+                       end
+
                        super.merge!(
                        {"state" => [@state],
                         "value" => [@value, :double],
-                        "tween.mode" => [@mode],
+                        "tween.mode" => [mode],
                         "tween.time" => [@time, :double],
                         "targets" => [@targets]})
                end