Sha256: 562cc69aa63c922601122413722ebd07d0bc950c7b651c95f98fca5ea05a091c

Contents?: true

Size: 855 Bytes

Versions: 42

Compression:

Stored size: 855 Bytes

Contents

module SctCore
    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 = SctCore::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

42 entries across 42 versions & 1 rubygems

Version Path
sct-1.10.2 sct_core/lib/sct_core/ui/ui.rb
sct-1.10.1 sct_core/lib/sct_core/ui/ui.rb
sct-1.10.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.9.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.8.2 sct_core/lib/sct_core/ui/ui.rb
sct-1.8.1 sct_core/lib/sct_core/ui/ui.rb
sct-1.8.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.7.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.6.3 sct_core/lib/sct_core/ui/ui.rb
sct-1.5.1 sct_core/lib/sct_core/ui/ui.rb
sct-1.5.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.4.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.3.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.2.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.1.2 sct_core/lib/sct_core/ui/ui.rb
sct-1.1.1 sct_core/lib/sct_core/ui/ui.rb
sct-1.1.0 sct_core/lib/sct_core/ui/ui.rb
sct-1.0.9 sct_core/lib/sct_core/ui/ui.rb
sct-1.0.8 sct_core/lib/sct_core/ui/ui.rb
sct-1.0.7 sct_core/lib/sct_core/ui/ui.rb