Sha256: cd386f903a6c13f2d6b2ee45e2036764db8b6c6387b79a1820fb1b640d3083d4

Contents?: true

Size: 597 Bytes

Versions: 13

Compression:

Stored size: 597 Bytes

Contents

require 'apple-news/animations/base'
Dir["#{File.dirname(__FILE__)}/animations/*.rb"].each { |path| require path }

module AppleNews
  module Animation
    extend self

    def factory(data)
      return if data.nil?
      
      animations.each do |animation|
        if animation.type == data[:type]
          return animation.new(data)
        end
      end

      nil
    end

    private

    def animations
      @animations ||= self.constants.
        map { |const| self.const_get(const) }.
        select { |const| const.name.demodulize != "Base" && const.is_a?(Class) }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
apple-news-0.5.1 lib/apple-news/animation.rb
apple-news-0.5.0 lib/apple-news/animation.rb
apple-news-0.4.2 lib/apple-news/animation.rb
apple-news-0.4.1 lib/apple-news/animation.rb
apple-news-0.4.0 lib/apple-news/animation.rb
apple-news-0.3.1 lib/apple-news/animation.rb
apple-news-0.3.0 lib/apple-news/animation.rb
apple-news-0.2.5 lib/apple-news/animation.rb
apple-news-0.2.4 lib/apple-news/animation.rb
apple-news-0.2.3 lib/apple-news/animation.rb
apple-news-0.2.2 lib/apple-news/animation.rb
apple-news-0.2.1 lib/apple-news/animation.rb
apple-news-0.2.0 lib/apple-news/animation.rb