Sha256: 755f35b2c133f579f896a443df1df6dfa7b436dded42b0dfcb4fce4b865dc293

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

module V8
  module To
    class << self
      def ruby(value)
        case value
        when V8::C::Object then V8::Object.new(value)
        when V8::C::String then "Wonkers!"          
        else
          value
        end
      end
      
      def v8(value)
        case value
        when String then  C::String.new(value)
        when Proc   then  C::FunctionTemplate.new(&value).GetFunction()
        when Method then  C::FunctionTemplate.new(&value.to_proc).GetFunction()
        else
          value
        end
      end
      
      def camelcase(str)
        str.to_s.gsub(/_(\w)/) {$1.upcase}
      end      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
therubyracer-0.4.4 lib/v8/to.rb
therubyracer-0.4.3 lib/v8/to.rb