org.jruby.Ruby.getHash()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中org.jruby.Ruby.getHash方法的一些代码示例,展示了Ruby.getHash的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getHash方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getHash

Ruby.getHash介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-core

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst();
  5. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst();
  5. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst(buckets);
  5. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst();
  5. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. if (buckets <= 0) buckets = 1; // FIXME: this hash implementation cannot deal with no buckets so we will add a single one (this constructor will go away once open addressing is added back).
  5. allocFirst(buckets);
  6. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public static IRubyObject checkHashType(Ruby runtime, IRubyObject obj) {
  2. if (obj instanceof RubyHash) return obj;
  3. return TypeConverter.convertToTypeWithCheck(obj, runtime.getHash(), "to_hash");
  4. }

代码示例来源:origin: org.jruby/jruby-core

  1. public RubyHash(Ruby runtime, IRubyObject defaultValue, int buckets) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. if (buckets <= 0) buckets = 1; // FIXME: this hash implementation cannot deal with no buckets so we will add a single one (this constructor will go away once open addressing is added back).
  5. allocFirst(buckets);
  6. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst();
  5. for (Iterator iter = valueMap.entrySet().iterator();iter.hasNext();) {
  6. Map.Entry e = (Map.Entry)iter.next();
  7. internalPut((IRubyObject)e.getKey(), (IRubyObject)e.getValue());
  8. }
  9. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) {
  2. super(runtime, runtime.getHash());
  3. this.ifNone = defaultValue;
  4. allocFirst();
  5. for (Iterator iter = valueMap.entrySet().iterator();iter.hasNext();) {
  6. Map.Entry e = (Map.Entry)iter.next();
  7. internalPut((IRubyObject)e.getKey(), (IRubyObject)e.getValue());
  8. }
  9. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Tries to convert this object to a Ruby Hash using the "to_hash"
  3. * method.
  4. */
  5. public RubyHash convertToHash() {
  6. return (RubyHash)TypeConverter.convertToType(this, getRuntime().getHash(), "to_hash");
  7. }

代码示例来源:origin: org.jruby/jruby-complete

  1. private static IRubyObject toHash(ThreadContext context, IRubyObject lastArg) {
  2. if (lastArg instanceof RubyHash) return (RubyHash) lastArg;
  3. if (lastArg.respondsTo("to_hash")) {
  4. lastArg = lastArg.callMethod(context, "to_hash");
  5. if (lastArg == context.nil) return lastArg;
  6. TypeConverter.checkType(context, lastArg, context.runtime.getHash());
  7. return (RubyHash) lastArg;
  8. }
  9. return null;
  10. }

代码示例来源:origin: org.jruby/jruby-core

  1. private static IRubyObject toHash(ThreadContext context, IRubyObject lastArg) {
  2. if (lastArg instanceof RubyHash) return (RubyHash) lastArg;
  3. if (lastArg.respondsTo("to_hash")) {
  4. lastArg = lastArg.callMethod(context, "to_hash");
  5. if (lastArg == context.nil) return lastArg;
  6. TypeConverter.checkType(context, lastArg, context.runtime.getHash());
  7. return (RubyHash) lastArg;
  8. }
  9. return null;
  10. }

代码示例来源:origin: org.jruby/jruby-complete

  1. @JRubyMethod
  2. public RubyHash to_h(ThreadContext context) {
  3. final Ruby runtime = context.runtime;
  4. return getType() == runtime.getHash() ? this : newHash(runtime).replace(context, this);
  5. }

代码示例来源:origin: org.jruby/jruby-complete

  1. /**
  2. * Tries to convert this object to a Ruby Hash using the "to_hash" method.
  3. * @return hash representation of this
  4. */
  5. @Override
  6. public RubyHash convertToHash() {
  7. Ruby runtime = getRuntime();
  8. ThreadContext context = runtime.getCurrentContext();
  9. BasicObjectSites sites = sites(context);
  10. return (RubyHash) TypeConverter.convertToType(context, this, runtime.getHash(), sites.to_hash_checked);
  11. }

代码示例来源:origin: asciidoctor/asciidoctorj

  1. private String formatMessage(final IRubyObject msg) {
  2. if (getRuntime().getString().equals(msg.getType())) {
  3. return msg.asJavaString();
  4. } else if (getRuntime().getHash().equals(msg.getType())) {
  5. final RubyHash hash = (RubyHash) msg;
  6. return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT)));
  7. }
  8. throw new IllegalArgumentException(Objects.toString(msg));
  9. }

代码示例来源:origin: org.asciidoctor/asciidoctorj

  1. private String formatMessage(final IRubyObject msg) {
  2. if (getRuntime().getString().equals(msg.getType())) {
  3. return msg.asJavaString();
  4. } else if (getRuntime().getHash().equals(msg.getType())) {
  5. final RubyHash hash = (RubyHash) msg;
  6. return Objects.toString(hash.get(getRuntime().newSymbol(LOG_PROPERTY_TEXT)));
  7. }
  8. throw new IllegalArgumentException(Objects.toString(msg));
  9. }

代码示例来源:origin: asciidoctor/asciidoctorj

  1. private Cursor getSourceLocation(IRubyObject msg) {
  2. if (getRuntime().getHash().equals(msg.getType())) {
  3. final RubyHash hash = (RubyHash) msg;
  4. final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION));
  5. return new CursorImpl((IRubyObject) sourceLocation);
  6. }
  7. return null;
  8. }
  9. }

代码示例来源:origin: org.asciidoctor/asciidoctorj

  1. private Cursor getSourceLocation(IRubyObject msg) {
  2. if (getRuntime().getHash().equals(msg.getType())) {
  3. final RubyHash hash = (RubyHash) msg;
  4. final Object sourceLocation = hash.get(getRuntime().newSymbol(LOG_PROPERTY_SOURCE_LOCATION));
  5. return new CursorImpl((IRubyObject) sourceLocation);
  6. }
  7. return null;
  8. }
  9. }

代码示例来源:origin: org.jruby/jruby-complete

  1. @JRubyMethod(name = "sub!", reads = BACKREF, writes = BACKREF)
  2. public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) {
  3. Ruby runtime = context.runtime;
  4. IRubyObject hash = TypeConverter.convertToTypeWithCheck(context, arg1, runtime.getHash(), sites(context).to_hash_checked);
  5. frozenCheck();
  6. if (hash == context.nil) {
  7. return subBangNoIter(context, asRegexpArg(runtime, arg0), arg1.convertToString());
  8. }
  9. return subBangIter(context, asRegexpArg(runtime, arg0), (RubyHash) hash, block);
  10. }

代码示例来源:origin: org.jruby/jruby-core

  1. @JRubyMethod(name = "sub!", reads = BACKREF, writes = BACKREF)
  2. public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) {
  3. Ruby runtime = context.runtime;
  4. IRubyObject hash = TypeConverter.convertToTypeWithCheck(context, arg1, runtime.getHash(), sites(context).to_hash_checked);
  5. frozenCheck();
  6. if (hash == context.nil) {
  7. return subBangNoIter(context, asRegexpArg(runtime, arg0), arg1.convertToString());
  8. }
  9. return subBangIter(context, asRegexpArg(runtime, arg0), (RubyHash) hash, block);
  10. }

相关文章

Ruby类方法