Sha256: 1fd4084a8b2c3a57ccdffcd83039decdacd882eb7a13ce0dcd0fc49ff8b1ca94

Contents?: true

Size: 593 Bytes

Versions: 4

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  ##
  # Screen registry. The screens call add_screen right after they are declared.
  module Screens
    class << self
      def screen_registry
        @screen_registry ||= {}
      end

      def add_screen(name, screen_class)
        unless screen_class < RubyJard::Screen
          raise RubyJard::Error, "#{screen_class} must implement, and inherit from #{RubyJard::Screen}"
        end

        screen_registry[name] = screen_class
      end

      def [](name)
        screen_registry[name]
      end
      alias get []
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_jard-0.2.2 lib/ruby_jard/screens.rb
ruby_jard-0.2.1 lib/ruby_jard/screens.rb
ruby_jard-0.2.0 lib/ruby_jard/screens.rb
ruby_jard-0.1.0 lib/ruby_jard/screens.rb