Home
Categories
Dictionary
Download
Project Details
Changes Log
FAQ
License

Ruby parsing example



This article shows an example of parsing for a Ruby Script.

Script interface

Suppose the following script interface:
      public interface Script extends ContextListener {
        public String execute();
      }

Ruby script

We have the following script:
      def execute()
        return context.getScriptFile().getName()
      end

Final result

      require 'java'
      import 'org.scripthelper.context.ScriptContext'
      import 'org.scripthelper.context.ScriptHelper'
      import 'org.scripthelper.context.ContextListener'
      import 'org.scripthelper.context.DefaultScriptContext'
      class ScriptClass
      java_implements 'org.scripthelper.context.ContextListener', 'org.scripthelper.ruby.samples.Script'
      _ attr_reader :context
      _ def init(ctx)
      _   @context = ctx
      _ end
      _ def execute()
      _   return context.getScriptFile().getName()
      _ end
      end

See also


Categories: dev | impls

Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence