Class: Mustang::V8::Date

Inherits:
Value show all
Includes:
Comparable, Delegated
Defined in:
lib/mustang/v8/date.rb,
ext/v8/v8_date.cpp

Class Method Summary collapse

Instance Method Summary collapse

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?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Delegated

Class Method Details

.V8::Date.new(time) ⇒ Object

Returns new V8 date reflected from given ruby time value.



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

static VALUE rb_v8_date_new(VALUE klass, VALUE time)
{
  HandleScope scope;
  PREVENT_CREATION_WITHOUT_CONTEXT();  
  return v8_ref_new(klass, to_v8_date(time));
}

Instance Method Details

#<=>(other) ⇒ Object



11
12
13
# File 'lib/mustang/v8/date.rb', line 11

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

#delegateObject



15
16
17
# File 'lib/mustang/v8/date.rb', line 15

def delegate
  to_time
end

#to_iObject

Returns integer value representation of referenced v8 date.



42
43
44
45
46
# File 'ext/v8/v8_date.cpp', line 42

static VALUE rb_v8_date_to_i(VALUE self)
{
  HandleScope scope;
  return rb_int_new(unwrap(self)->NumberValue());
}

#to_timeObject



7
8
9
# File 'lib/mustang/v8/date.rb', line 7

def to_time
  Time.at(to_i);
end