Class: String
Instance Method Summary collapse
- #as_blank? ⇒ Boolean
- #ascii_8bit ⇒ Object (also: #as_ascii_8bit, #as_8bit_ascii)
- #blank? ⇒ Boolean
- #mri_blank? ⇒ Boolean
- #present? ⇒ Boolean
Instance Method Details
#as_blank? ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'ext/faster_support/core_ext/object/blank/string_blank.c', line 9 static VALUE rb_str_as_blank(VALUE str) { rb_encoding *enc; char *s, *e; enc = STR_ENC_GET(str); s = RSTRING_PTR(str); if (!s || RSTRING_LEN(str) == 0) return Qtrue; e = RSTRING_END(str); while (s < e) { int n; unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc); switch (cc) { case 9: case 0xa: case 0xb: case 0xc: case 0xd: case 0x20: case 0x85: case 0xa0: case 0x1680: case 0x2000: case 0x2001: case 0x2002: case 0x2003: case 0x2004: case 0x2005: case 0x2006: case 0x2007: case 0x2008: case 0x2009: case 0x200a: case 0x2028: case 0x2029: case 0x202f: case 0x205f: case 0x3000: #if RUBY_BEFORE_2_2 case 0x180e: #endif /* found a blank char */ break; default: return Qfalse; } s += n; } /* if we get here, all chars were blank chars */ return Qtrue; } |
#ascii_8bit ⇒ Object Also known as: as_ascii_8bit, as_8bit_ascii
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'ext/faster_support/core_ext/string/string.c', line 7 static VALUE rb_str_to_ascii8bit(VALUE str) { rb_encoding *enc; VALUE new_str; enc = STR_ENC_GET(str); if (enc == ascii_8bit_enc) { return str; } if (OBJ_FROZEN(str)) { new_str = rb_obj_dup(str); } else { new_str = str; } rb_check_frozen(new_str); rb_enc_associate(new_str, ascii_8bit_enc); ENC_CODERANGE_CLEAR(new_str); return new_str; } |
#blank? ⇒ Boolean
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'ext/faster_support/core_ext/object/blank/string_blank.c', line 90 static VALUE rb_str_blank(VALUE str) { FasterSupport_blank_impl impl = FasterSupport_get_blank_impl(); switch (impl) { case Impl_MRI: return rb_str_mri_blank(str); case Impl_ActiveSupport: return rb_str_as_blank(str); default: break; } return rb_str_as_blank(str); } |
#mri_blank? ⇒ Boolean
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'ext/faster_support/core_ext/object/blank/string_blank.c', line 68 static VALUE rb_str_mri_blank(VALUE str) { rb_encoding *enc; char *s, *e; enc = STR_ENC_GET(str); s = RSTRING_PTR(str); if (!s || RSTRING_LEN(str) == 0) return Qtrue; e = RSTRING_END(str); while (s < e) { int n; unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc); if (!rb_isspace(cc) && cc != 0) return Qfalse; s += n; } return Qtrue; } |
#present? ⇒ Boolean
106 107 108 109 |
# File 'ext/faster_support/core_ext/object/blank/string_blank.c', line 106 static VALUE rb_str_present(VALUE str) { return RB_NEGATE(rb_str_blank(str)); } |