2009-12-18 09:48:06 +02:00
|
|
|
|
|
|
|
module V8
|
|
|
|
module To
|
|
|
|
class << self
|
|
|
|
def ruby(value)
|
|
|
|
case value
|
|
|
|
when V8::C::Object then V8::Object.new(value)
|
2009-12-20 19:31:02 +02:00
|
|
|
when V8::C::String then "Wonkers!"
|
2009-12-18 09:48:06 +02:00
|
|
|
else
|
|
|
|
value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def v8(value)
|
|
|
|
case value
|
|
|
|
when String then C::String.new(value)
|
|
|
|
when Proc then C::FunctionTemplate.new(&value).GetFunction()
|
2009-12-20 19:31:02 +02:00
|
|
|
when Method then C::FunctionTemplate.new(&value.to_proc).GetFunction()
|
2009-12-18 09:48:06 +02:00
|
|
|
else
|
|
|
|
value
|
|
|
|
end
|
|
|
|
end
|
2010-01-10 11:37:51 +02:00
|
|
|
|
|
|
|
def camelcase(str)
|
|
|
|
str.to_s.gsub(/_(\w)/) {$1.upcase}
|
|
|
|
end
|
2009-12-18 09:48:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|