Created
January 18, 2016 17:15
-
-
Save littlemove/7afaba938957950ec202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'execjs' | |
# JS file path with the Kigo price calculation algorithm. | |
kigo_js_path = "#{Rails.root}/db/kigo_price_calculation.js" | |
source = %Q( | |
var price_info = '{}'; | |
var checkin = new Date('2016-05-07'); | |
var checkout = new Date('2016-05-17'); | |
var guests = 2; | |
#{File.read(kigo_js_path)} | |
) | |
ExecJS.exec(source) |
pacoguzman
commented
Jan 18, 2016
ctx = ExecJS.compile('function wadus(guests) { return "number of guests: " + guests;};')
=> #<ExecJS::ExternalRuntime::Context:0x007f97fa3bfa08
ctx.call("wadus", 3)
=> "number of guests: 3"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment