Class: V8::String

Inherits:
Primitive show all
Includes:
Comparable, Delegated
Defined in:
lib/v8/string.rb,
ext/v8/v8_string.cpp

Class Method Summary collapse

Instance Method Summary collapse

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?

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::String.new(str) ⇒ Object

Returns new V8 string reflected from given string.



28
29
30
31
32
33
# File 'ext/v8/v8_string.cpp', line 28

static VALUE rb_v8_string_new(VALUE klass, VALUE data)
{
  HandleScope scope;
  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



19
20
21
# File 'lib/v8/string.rb', line 19

def <=>(other)
  to_s <=> other
end

#delegateObject



23
24
25
# File 'lib/v8/string.rb', line 23

def delegate
  to_s
end

#native_to_utf8Object



7
# File 'lib/v8/string.rb', line 7

alias_method :native_to_utf8, :to_utf8

#to_asciiObject

Returns ASCII representation of referenced string.



56
57
58
59
60
# File 'ext/v8/v8_string.cpp', line 56

static VALUE rb_v8_string_to_ascii(VALUE self)
{
  HandleScope scope;
  return rb_str_new2(*String::AsciiValue(unwrap(self)));
}

#to_utf8Object #to_sObject Also known as: to_s

Returns UTF-8 representation of referenced string.



43
44
45
# File 'ext/v8/v8_string.cpp', line 43

def to_utf8
  native_to_utf8.force_encoding("UTF-8")
end