Class: V8::Integer
- Includes:
- Comparable, Delegated
- Defined in:
- lib/v8/integer.rb,
ext/v8/v8_integer.cpp
Class Method Summary collapse
-
.V8::Integer.new(int) ⇒ Object
Returns new V8 integer reflected from given fixnum value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #delegate ⇒ Object
-
#to_i ⇒ Object
Returns fixnum value representation of referenced v8 integer.
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::Integer.new(int) ⇒ Object
Returns new V8 integer reflected from given fixnum value.
28 29 30 31 32 33 |
# File 'ext/v8/v8_integer.cpp', line 28
static VALUE rb_v8_integer_new(VALUE klass, VALUE data)
{
HandleScope scope;
VALUE num = rb_funcall2(data, rb_intern("to_i"), 0, NULL);
return v8_ref_new(klass, to_v8_integer(num));
}
|
Instance Method Details
#<=>(other) ⇒ Object
8 9 10 |
# File 'lib/v8/integer.rb', line 8 def <=>(other) to_i <=> other end |
#delegate ⇒ Object
12 13 14 |
# File 'lib/v8/integer.rb', line 12 def delegate to_i end |
#to_i ⇒ Object
Returns fixnum value representation of referenced v8 integer.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'ext/v8/v8_integer.cpp', line 42
static VALUE rb_v8_integer_to_i(VALUE self)
{
HandleScope scope;
Local<Integer> num = unwrap(self);
if (num->IsUint32()) {
return UINT2NUM(num->Uint32Value());
} else if (num->IsInt32()) {
return INT2NUM(num->Int32Value());
} else {
return INT2NUM(0);
}
}
|