Class: Walt::AnimationSet

Inherits:
Object
  • Object
show all
Extended by:
Support::AttrDefault
Defined in:
lib/walt/animation_set.rb

Constant Summary collapse

PROPERTIES =
[:animations, :assets]

Instance Method Summary collapse

Methods included from Support::AttrDefault

attr_default

Constructor Details

#initialize(params = {}) ⇒ AnimationSet

Returns a new instance of AnimationSet.



16
17
18
19
20
21
22
# File 'lib/walt/animation_set.rb', line 16

def initialize(params = {})
  params.each do |key, value|
    if PROPERTIES.include?(key.to_sym)
      self.send("#{key}=", value)
    end
  end
end

Instance Method Details

#animateObject



57
58
59
60
61
62
# File 'lib/walt/animation_set.rb', line 57

def animate
  self.animations.each do |animation|
    animation.assets = self.assets
    animation.animate
  end
end

#animations=(animations) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/walt/animation_set.rb', line 25

def animations=(animations)
  _animations = animations && animations.collect do |animation|
    case animation
    when Walt::Animation
      animation
    when NSDictionary
      Walt::Animation.new(animation)
    else
      raise "Invalid class for animation #{animation.inspect}"
    end
  end
  @animations = _animations
end

#assets=(assets) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/walt/animation_set.rb', line 40

def assets=(assets)
  _assets = assets && assets.collect do |asset|
    case asset
    when Walt::Asset
      asset
    when NSDictionary
      Walt::Asset.for(asset)
    when UIView
      Walt::Asset.for(asset)
    else
      raise "Invalid class for asset #{asset.inspect}"
    end
    asset
  end
  @assets = _assets
end