当前位置: 首页>>代码示例>>Java>>正文


Java Ruby.newString方法代码示例

本文整理汇总了Java中org.jruby.Ruby.newString方法的典型用法代码示例。如果您正苦于以下问题:Java Ruby.newString方法的具体用法?Java Ruby.newString怎么用?Java Ruby.newString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.Ruby的用法示例。


在下文中一共展示了Ruby.newString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyLoadPaths

import org.jruby.Ruby; //导入方法依赖的package包/类
/**
 * applyLoadPaths
 * 
 * @param container
 */
protected void applyLoadPaths(Ruby runtime)
{
	if (this._loadPaths != null && this._loadPaths.size() > 0)
	{
		IRubyObject object = runtime.getLoadService().getLoadPath();

		if (object instanceof RubyArray)
		{
			RubyArray loadPathArray = (RubyArray) object;

			// save copy for later
			this._originalLoadPaths = (RubyArray) loadPathArray.dup();

			// Add our custom load paths
			for (String loadPath : this._loadPaths)
			{
				RubyString toAdd = runtime.newString(loadPath.replace('\\', '/'));

				loadPathArray.append(toAdd);
			}
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:29,代码来源:AbstractScriptRunner.java

示例2: inspect

import org.jruby.Ruby; //导入方法依赖的package包/类
@JRubyMethod(name = "inspect")
public IRubyObject inspect(ThreadContext context) {
    Ruby runtime = getRuntime();
    String className = getMetaClass().getRealClass().getName();
    return runtime.newString(className + this.toRubyArray(context).inspect());
}
 
开发者ID:Who828,项目名称:persistent_data_structures,代码行数:7,代码来源:PersistentVectorLibrary.java

示例3: buildSelfString

import org.jruby.Ruby; //导入方法依赖的package包/类
/**
 * This is a kind of pointless module class method, but is simple to understand. 
 * meta = true is waht makes this module class method
 * The equivalent in ruby: 
 * module Foo 
 *   def self.self_string
 *     return 'This is String is from Foo.self' 
 *   end
 * end
 *
 * @param context ThreadContext
 * @param recv the receiver
 * @return A RubyString.
 */

@JRubyMethod(name = "self_string", module = true, meta = true)
public static IRubyObject buildSelfString(ThreadContext context, IRubyObject recv) {
    Ruby runtime = context.getRuntime();
    return runtime.newString("This is String is from Foo.self");
}
 
开发者ID:jruby,项目名称:jruby-examples,代码行数:21,代码来源:RubyFoo.java

示例4: buildString

import org.jruby.Ruby; //导入方法依赖的package包/类
/**
 * Example ruby aliases that return a string. This is a kind of pointless
 * method, but is simple to understand. The equivalent in ruby: 
 * module Foo 
 *   def build_string
 *     return 'This is a new String' 
 *   end alias_method :build_string :new_string
 * end
 *
 * @param context ThreadContext
 * @param recv the receiver
 * @return A RubyString.
 */
@JRubyMethod(name = {"build_string", "new_string"}, module = true)
public static IRubyObject buildString(ThreadContext context, IRubyObject recv) {
    Ruby runtime = context.getRuntime();
    return runtime.newString("This is a new String");
}
 
开发者ID:jruby,项目名称:jruby-examples,代码行数:19,代码来源:RubyFoo.java

示例5: pigToRuby

import org.jruby.Ruby; //导入方法依赖的package包/类
/**
 * A type specific conversion routine.
 *
 * @param ruby   the Ruby runtime to create objects in
 * @param object object to convert
 * @return       analogous Ruby type
 */
public static RubyString pigToRuby(Ruby ruby, String object) {
    return ruby.newString(object.toString());
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:11,代码来源:PigJrubyLibrary.java


注:本文中的org.jruby.Ruby.newString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。