Module: IRuby::Utils

Included in:
IRuby
Defined in:
lib/iruby/utils.rb

Instance Method Summary collapse

Instance Method Details

#convert(object, options) ⇒ Object



3
4
5
# File 'lib/iruby/utils.rb', line 3

def convert(object, options)
  Display.convert(object, options)
end

#display(obj, options = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/iruby/utils.rb', line 7

def display(obj, options = {})
  Kernel.instance.session.send(:publish, :display_data,
                               data: Display.display(obj, options),
                               metadata: {},
                               source: 'ruby') unless obj.nil?
end

#html(s) ⇒ Object



27
28
29
# File 'lib/iruby/utils.rb', line 27

def html(s)
  convert(s, mime: 'text/html')
end

#javascript(s) ⇒ Object



31
32
33
# File 'lib/iruby/utils.rb', line 31

def javascript(s)
  convert(s, mime: 'application/javascript')
end

#latex(s) ⇒ Object Also known as: tex



18
19
20
# File 'lib/iruby/utils.rb', line 18

def latex(s)
  convert(s, mime: 'text/latex')
end

#math(s) ⇒ Object



23
24
25
# File 'lib/iruby/utils.rb', line 23

def math(s)
  convert("$$#{s}$$", mime: 'text/latex')
end

#svg(s) ⇒ Object



35
36
37
# File 'lib/iruby/utils.rb', line 35

def svg(s)
  convert(s, mime: 'image/svg+xml')
end

#table(s, **options) ⇒ Object



14
15
16
# File 'lib/iruby/utils.rb', line 14

def table(s, **options)
  html(HTML.table(s, options))
end