Class: RubyRunJs::JsDate

Inherits:
JsBaseObject show all
Defined in:
lib/ruby_run_js/objects/js_date.rb

Instance Attribute Summary collapse

Attributes inherited from JsBaseObject

#_class, #extensible, #own, #prototype, #value

Instance Method Summary collapse

Methods inherited from JsBaseObject

#_type, #can_put, #default_value, #define_own_property, #delete, #get, #get_items, #get_own_property, #get_property, #has_property, #put, #set_items

Methods included from Helper

#check_object, #get_member, #get_member_dot, #is_accessor_descriptor, #is_callable, #is_data_descriptor, #is_generic_descriptor, #is_primitive, #make_error, #strict_equality

Methods included from ConversionHelper

#convert_to_js_type, #to_boolean, #to_int32, #to_integer, #to_number, #to_object, #to_primitive, #to_string, #to_uint16, #to_uint32

Constructor Details

#initialize(value, prototype) ⇒ JsDate

Returns a new instance of JsDate.



9
10
11
12
13
14
# File 'lib/ruby_run_js/objects/js_date.rb', line 9

def initialize(value, prototype)
  super()
  @prototype = prototype
  set_value(value)
  @_class = 'Date'
end

Instance Attribute Details

#rb_timeObject (readonly)

Returns the value of attribute rb_time.



7
8
9
# File 'lib/ruby_run_js/objects/js_date.rb', line 7

def rb_time
  @rb_time
end

Instance Method Details

#set_value(value) ⇒ Object



16
17
18
19
# File 'lib/ruby_run_js/objects/js_date.rb', line 16

def set_value(value)
  @value = value
  @rb_time = value != value ? nil : Time.at(value / 1000.0)
end