本文整理汇总了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);
}
}
}
}
示例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());
}
示例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");
}
示例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");
}
示例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());
}