Class: Mustang::V8::String
- Includes:
- Comparable, Delegated
- Defined in:
- lib/mustang/v8/string.rb,
ext/v8/v8_string.cpp
Class Method Summary collapse
-
.V8::String.new(str) ⇒ Object
Returns new V8 string reflected from given string.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #delegate ⇒ Object
- #kind_of?(klass) ⇒ Boolean
- #native_to_utf8 ⇒ Object
-
#to_ascii ⇒ Object
Returns ASCII representation of referenced string.
-
#to_utf8 ⇒ Object
(also: #to_s)
Returns UTF-8 representation of referenced string.
Methods included from Delegated
#method_missing, #old_method_missing, #old_respond_to?, #respond_to?
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?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Delegated
Class Method Details
.V8::String.new(str) ⇒ Object
Returns new V8 string reflected from given string.
28 29 30 31 32 33 34 |
# File 'ext/v8/v8_string.cpp', line 28
static VALUE rb_v8_string_new(VALUE klass, VALUE data)
{
HandleScope scope;
PREVENT_CREATION_WITHOUT_CONTEXT();
VALUE str = rb_funcall2(data, rb_intern("to_s"), 0, NULL);
return v8_ref_new(klass, to_v8_string(str));
}
|
Instance Method Details
#<=>(other) ⇒ Object
18 19 20 |
# File 'lib/mustang/v8/string.rb', line 18 def <=>(other) to_s <=> other end |
#delegate ⇒ Object
22 23 24 |
# File 'lib/mustang/v8/string.rb', line 22 def delegate to_s end |
#kind_of?(klass) ⇒ Boolean
26 27 28 |
# File 'lib/mustang/v8/string.rb', line 26 def kind_of?(klass) klass == ::String or super(klass) end |
#native_to_utf8 ⇒ Object
6 |
# File 'lib/mustang/v8/string.rb', line 6 alias_method :native_to_utf8, :to_utf8 |
#to_ascii ⇒ Object
Returns ASCII representation of referenced string.
57 58 59 60 61 |
# File 'ext/v8/v8_string.cpp', line 57
static VALUE rb_v8_string_to_ascii(VALUE self)
{
HandleScope scope;
return rb_str_new2(*String::AsciiValue(unwrap(self)));
}
|