Module: GRCommons::JupyterSupport

Included in:
GR, GR3
Defined in:
lib/gr_commons/jupyter_support.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(_obj) ⇒ Object



8
9
10
11
12
13
# File 'lib/gr_commons/jupyter_support.rb', line 8

def self.extended(_obj)
  require 'tempfile'
  ENV['GKSwstype'] = 'svg'
  # May be extended to both GR3 and GR
  ENV['GKS_FILEPATH'] = Tempfile.open(['plot', '.svg']).path
end

Instance Method Details

#showObject



15
16
17
18
19
20
21
# File 'lib/gr_commons/jupyter_support.rb', line 15

def show
  emergencyclosegks
  sleep 0.5
  svg = File.read(ENV['GKS_FILEPATH'])
  IRuby.display(svg, mime: 'image/svg+xml')
  nil
end