module GoogleVisualr

Public Class Methods

generate_init_code(dependent_js) click to toggle source

generate initializing code

# File lib/daru/view/adapters/googlecharts/iruby_notebook.rb, line 5
def self.generate_init_code(dependent_js)
  js_dir = File.expand_path(
    '../../../../../vendor/assets/javascripts/googlecharts', __dir__
  )
  path = File.expand_path(
    '../../templates/googlecharts/init.inline.js.erb', __dir__
  )
  template = File.read(path)
  ERB.new(template).result(binding)
end
init_iruby(dependent_js=GOOGLECHARTS_DEPENDENCIES_IRUBY) click to toggle source

Enable to show plots on IRuby notebook

# File lib/daru/view/adapters/googlecharts/iruby_notebook.rb, line 17
def self.init_iruby(dependent_js=GOOGLECHARTS_DEPENDENCIES_IRUBY)
  js = generate_init_code(dependent_js)
  IRuby.display(IRuby.javascript(js))
end
init_script( dependent_js=GOOGLECHARTS_DEPENDENCIES_WEB ) click to toggle source
# File lib/daru/view/adapters/googlecharts/google_visualr.rb, line 8
def self.init_script(
  dependent_js=GOOGLECHARTS_DEPENDENCIES_WEB
)
  js =  ''
  js << "\n<script type='text/javascript'>"
  js << GoogleVisualr.generate_init_code(dependent_js)
  js << "\n</script>"
  js
end