Class: Fukubukuro::ECMA::Core::ObjectWrapper

Inherits:
Container show all
Defined in:
lib/amber/fukubukuro/ecma_core.rb

Instance Attribute Summary

Attributes inherited from Container

#original, #value

Instance Method Summary collapse

Methods inherited from Container

bind_to_original, #inspect, inspect, #method_missing, #pretty_print, #value_inspect

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Fukubukuro::ECMA::Core::Container

Instance Method Details

#fuku_call(*args) ⇒ Object



392
393
394
# File 'lib/amber/fukubukuro/ecma_core.rb', line 392

def fuku_call *args
  ECMA.make_core_object_from value.send(:call, *args.map { |arg| arg.to_ruby })
end

#fuku_method_call(meth, *args) ⇒ Object



386
387
388
389
390
# File 'lib/amber/fukubukuro/ecma_core.rb', line 386

def fuku_method_call(meth, *args)
  raise "Can't method-call a setter method." if meth.to_s[-1] == ?=
  Fukubukuro::CurrentReceiver.set self
  ECMA.make_core_object_from value.send(meth).call(*args.map { |arg| arg.to_ruby })
end

#fuku_send(meth, *args) ⇒ Object



377
378
379
380
381
382
383
384
# File 'lib/amber/fukubukuro/ecma_core.rb', line 377

def fuku_send(meth, *args)
  if meth.to_s[-1] == ?=
    raise 'Expected 1 argument for member assignment; got %p' % [args.size] if args.size != 1
    value.send(meth, args.first.to_ruby)
  else
    ECMA.make_core_object_from value.send(meth, *args.map { |arg| arg.to_ruby })
  end
end