Class: V8::Regexp
- Includes:
- Delegated
- Defined in:
- lib/v8/regexp.rb,
ext/v8/v8_regexp.cpp
Class Method Summary collapse
-
.new(*args) ⇒ Object
Returns new V8 regexp reflected from given ruby regexp or source and flags.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
- #delegate ⇒ Object
-
#options ⇒ Integer
Returns fixnum value of v8 regexp flags.
-
#flags ⇒ Integer
Returns fixnum value of ruby regexp flags.
-
#source ⇒ String
Returns regexp source string.
- #to_regexp ⇒ Object
Methods included from Delegated
#method_missing, #old_method_missing, #old_respond_to?, #respond_to?, #to_s
Methods inherited from Value
#array?, #ary?, #bool?, #boolean?, #date?, #empty?, #external?, #false?, #func?, #function?, #int?, #integer?, #null?, #num?, #number?, #obj?, #object?, #regex?, #regexp?, #str?, #string?, #to_boolean, #to_integer, #to_number, #to_object, #to_string, #true?, #undefined?
Methods inherited from Data
#empty?, #error?, #null?, #undefined?, #value?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Delegated
Class Method Details
.V8::Regexp.new(rxp) ⇒ Regexp .V8::Regexp.new(str, flags) ⇒ Regexp
Returns new V8 regexp reflected from given ruby regexp or source and flags.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'ext/v8/v8_regexp.cpp', line 61
static VALUE rb_v8_regexp_new(int argc, VALUE *argv, VALUE klass)
{
HandleScope scope;
if (argc == 1) {
return v8_ref_new(klass, to_v8_regexp(argv[0]));
} else if (argc == 2) {
return v8_ref_new(klass, to_v8_regexp(argv[0], argv[1]));
} else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..2)", argc);
return Qnil;
}
}
|
Instance Method Details
#==(other) ⇒ Object
7 8 9 |
# File 'lib/v8/regexp.rb', line 7 def ==(other) to_regexp == other end |
#===(other) ⇒ Object
11 12 13 |
# File 'lib/v8/regexp.rb', line 11 def ===(other) to_regexp == other end |
#delegate ⇒ Object
15 16 17 |
# File 'lib/v8/regexp.rb', line 15 def delegate to_regexp end |
#options ⇒ Integer
Returns fixnum value of v8 regexp flags.
99 100 101 102 103 |
# File 'ext/v8/v8_regexp.cpp', line 99
static VALUE rb_v8_regexp_flags(VALUE self)
{
HandleScope scope;
return to_ruby(unwrap(self)->GetFlags());
}
|
#flags ⇒ Integer
Returns fixnum value of ruby regexp flags.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'ext/v8/v8_regexp.cpp', line 112
static VALUE rb_v8_regexp_options(VALUE self)
{
HandleScope scope;
int flags = (int)unwrap(self)->GetFlags();
int opts = 0;
if (flags & RegExp::kIgnoreCase) {
opts |= 1; // Regexp::IGNORECASE
}
if (flags & RegExp::kGlobal) {
opts |= 2; // Regexp::EXTENDED
}
if (flags & RegExp::kMultiline) {
opts |= 4; // Regexp::MULTILINE
}
return to_ruby(opts);
}
|
#source ⇒ String
86 87 88 89 90 |
# File 'ext/v8/v8_regexp.cpp', line 86
static VALUE rb_v8_regexp_source(VALUE self)
{
HandleScope scope;
return to_ruby(unwrap(self)->GetSource());
}
|
#to_regexp ⇒ Object
19 20 21 |
# File 'lib/v8/regexp.rb', line 19 def to_regexp ::Regexp.new(source, ) end |