Sha256: be3c0e06e121d5f555b308540d3f841207d10796046921750542a2748268ca45

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Ichabod
  module ScriptObject
    class Ruby
      attr_reader :runtime
    
      def initialize(runtime)
        @runtime = runtime
      end
      
      ##
      # Lets us call simple ruby methods
      #
      #   Ruby.IO_read(file)
      #   Ruby.puts('hi')
      #   Ruby.require('uri')
      def invokeUndefinedMethodFromWebScript(name, withArguments:args)
        if respond_to? name
          send(name, *args)
        elsif Kernel.respond_to? name
          Kernel.send(name, *args)
        elsif name =~ /^([A-Z][A-Za-z]+)_(.+)/
          const = Kernel.const_get($1)
          method = $2

          if const.respond_to? method
            const.send(method, *args)
          elsif const.respond_to?("#{method}?")
            const.send("#{method}?", *args)
          elsif const.respond_to?("#{method}!")
            const.send("#{method}!", *args)
          end
        end
      end

      ##
      # Ruby('$LOAD_PATH') => array...
      # Ruby('1 + 1') => 2
      def invokeDefaultMethodWithArguments(args)
        eval(args[0])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ichabod-0.0.2 lib/ichabod/script_object/ruby.rb
ichabod-0.0.1 lib/ichabod/script_object/ruby.rb