projects
/
redact.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Collection#script= and ExecScriptProgram#script= now accept a filename, too.
[redact.git]
/
lib
/
redact
/
program.rb
diff --git
a/lib/redact/program.rb
b/lib/redact/program.rb
index d6038d9646b82d17c75a499fa3e361d8d87884fa..2342b53a4fa5f90549625472c4d8f88f581756ec 100644
(file)
--- a/
lib/redact/program.rb
+++ b/
lib/redact/program.rb
@@
-1,5
+1,5
@@
#--
#--
-# $Id: program.rb
23 2005-04-02 23:20:32
Z tilman $
+# $Id: program.rb
71 2005-09-21 16:00:31
Z tilman $
#
# Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
#
#
# Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
#
@@
-35,8
+35,8
@@
module Redact
include Comparable
include Comparable
- attr_reader :collection, :id, :name, :after
-
attr_accessor :signal, :source,
:in_from, :in_range
+ attr_reader :collection, :id, :name, :after
, :signal, :source,
+
:in_from, :in_range
def initialize(collection, id, name)
@collection = collection
def initialize(collection, id, name)
@collection = collection
@@
-56,6
+56,35
@@
module Redact
@id <=> b.id
end
@id <=> b.id
end
+ def signal=(v)
+ @signal = v.to_str.dup
+ end
+
+ def source=(v)
+ @source = v.to_str.dup
+ end
+
+ def in_from=(v)
+ unless v.is_a?(Float)
+ raise(ArgumentError,
+ "wrong argument type #{v.class.name} " +
+ "(expected Float)")
+ end
+
+ @in_from = v
+ end
+
+ def in_range=(v)
+ unless v.is_a?(Float)
+ raise(ArgumentError,
+ "wrong argument type #{v.class.name} " +
+ "(expected Float)")
+ end
+
+ @in_range = v
+ end
+
+ protected
def to_eet_name
"Edje_Program"
end
def to_eet_name
"Edje_Program"
end
@@
-73,8
+102,8
@@
module Redact
end
class SetStateProgram < Program
end
class SetStateProgram < Program
- attr_reader :targets
- attr_accessor :
state, :value, :mode, :tim
e
+ attr_reader :targets
, :state, :value, :time
+ attr_accessor :
mod
e
def initialize(collection, id, name)
super
def initialize(collection, id, name)
super
@@
-87,6
+116,31
@@
module Redact
@targets = ProgramArgs.new(collection)
end
@targets = ProgramArgs.new(collection)
end
+ def state=(v)
+ @state = v.to_str.dup
+ end
+
+ def value=(v)
+ unless v.is_a?(Float)
+ raise(ArgumentError,
+ "wrong argument type #{v.class.name} " +
+ "(expected Float)")
+ end
+
+ @value = v
+ end
+
+ def time=(v)
+ unless v.is_a?(Float)
+ raise(ArgumentError,
+ "wrong argument type #{v.class.name} " +
+ "(expected Float)")
+ end
+
+ @time = v
+ end
+
+ protected
def to_eet_properties
mode = case @mode
when :linear: 1
def to_eet_properties
mode = case @mode
when :linear: 1
@@
-114,22
+168,32
@@
module Redact
@targets = ProgramArgs.new(collection)
end
@targets = ProgramArgs.new(collection)
end
+ protected
def to_eet_properties
super.merge!({"targets" => [@targets]})
end
end
class EmitSignalProgram < Program
def to_eet_properties
super.merge!({"targets" => [@targets]})
end
end
class EmitSignalProgram < Program
- attr_
accesso
r :emission_signal, :emission_source
+ attr_
reade
r :emission_signal, :emission_source
def initialize(collection, id, name)
super
@type = TYPE_EMIT_SIGNAL
def initialize(collection, id, name)
super
@type = TYPE_EMIT_SIGNAL
- @emission_signal = nil
- @emission_source = nil
+ @emission_signal = ""
+ @emission_source = ""
+ end
+
+ def emission_signal=(v)
+ @emission_signal = v.to_str.dup
end
end
+ def emission_source=(v)
+ @emission_source = v.to_str.dup
+ end
+
+ protected
def to_eet_properties
super.merge!(
{"state" => [@emission_signal],
def to_eet_properties
super.merge!(
{"state" => [@emission_signal],
@@
-138,7
+202,7
@@
module Redact
end
class ExecScriptProgram < Program
end
class ExecScriptProgram < Program
- attr_
accesso
r :script
+ attr_
reade
r :script
def initialize(collection, id, name)
super
def initialize(collection, id, name)
super
@@
-146,6
+210,11
@@
module Redact
@type = TYPE_EXEC_SCRIPT
@script = nil
end
@type = TYPE_EXEC_SCRIPT
@script = nil
end
+
+ def script=(v)
+ v = v.to_str
+ @script = (File.exist?(v) ? File.read(v) : v).dup
+ end
end
class ProgramArgs < Array
end
class ProgramArgs < Array
@@
-172,18
+241,21
@@
module Redact
@id = v.id
end
@id = v.id
end
+ protected
def to_eet_properties
{"id" => [@id]}
end
end
class ProgramAfter < ProgramArg
def to_eet_properties
{"id" => [@id]}
end
end
class ProgramAfter < ProgramArg
+ protected
def to_eet_name
"Edje_Program_After"
end
end
class ProgramTarget < ProgramArg
def to_eet_name
"Edje_Program_After"
end
end
class ProgramTarget < ProgramArg
+ protected
def to_eet_name
"Edje_Program_Target"
end
def to_eet_name
"Edje_Program_Target"
end