Sha256: f46b608bb11a0fdf2da9a4f2e87dfef54fe5c3711a38926a309e2bd12ec09c13

Contents?: true

Size: 820 Bytes

Versions: 18

Compression:

Stored size: 820 Bytes

Contents

module PantographCore
  class UI
    class << self
      attr_accessor(:ui_object)

      def ui_object
        require_relative 'implementations/shell'
        @ui_object ||= Shell.new
      end

      def method_missing(method_sym, *args, &_block)
        # not using `responds` because we don't care about methods like .to_s and so on
        require_relative 'interface'
        interface_methods = PantographCore::Interface.instance_methods - Object.instance_methods
        UI.user_error!("Unknown method '#{method_sym}', supported #{interface_methods}") unless interface_methods.include?(method_sym)

        self.ui_object.send(method_sym, *args)
      end
    end
  end
end

# Import all available implementations
Dir[File.dirname(__FILE__) + '/implementations/*.rb'].each do |file|
  require_relative file
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pantograph-0.1.22 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.21 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.20 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.19 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.17 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.16 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.15 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.14 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.13 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.12 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.10 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.8 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.7 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.6 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.4 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.3 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.1 pantograph_core/lib/pantograph_core/ui/ui.rb
pantograph-0.1.0 pantograph_core/lib/pantograph_core/ui/ui.rb