Class: RKelly::JS::String

Inherits:
Base
  • Object
show all
Defined in:
lib/rkelly/js/string.rb

Instance Attribute Summary

Attributes inherited from Base

#properties, #return, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #can_put?, #default_value, #delete, #has_property?, #returned?

Constructor Details

#initialize(value) ⇒ String

Returns a new instance of String.



10
11
12
13
14
15
16
17
18
# File 'lib/rkelly/js/string.rb', line 10

def initialize(value)
  super()
  self['valueOf'] = value
  self['valueOf'].function = lambda { value }
  self['toString'] = value
  self['fromCharCode'] = unbound_method(:fromCharCode) { |*args|
    args.map { |x| x.chr }.join
  }
end

Class Method Details

.create(*args) ⇒ Object



5
6
7
# File 'lib/rkelly/js/string.rb', line 5

def create(*args)
  self.new(args.first || '')
end