Class: Mustang::V8::String

Inherits:
Primitive show all
Includes:
Comparable, Delegated
Defined in:
lib/mustang/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?

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

#delegateObject



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

def delegate
  to_s
end

#native_to_utf8Object



6
# File 'lib/mustang/v8/string.rb', line 6

alias_method :native_to_utf8, :to_utf8

#to_asciiObject

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)));
}

#to_utf8Object #to_sObject Also known as: to_s

Returns UTF-8 representation of referenced string.



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

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