Module: IRuby::Display
- Defined in:
- lib/iruby/display.rb
Defined Under Namespace
Modules: Registry
Classes: Renderer, Representation
Class Method Summary
collapse
Class Method Details
.clear_output(wait = false) ⇒ Object
35
36
37
|
# File 'lib/iruby/display.rb', line 35
def clear_output(wait=false)
IRuby::Kernel.instance.session.send(:publish, :clear_output, {wait: wait})
end
|
.convert(obj, options) ⇒ Object
4
5
6
|
# File 'lib/iruby/display.rb', line 4
def convert(obj, options)
Representation.new(obj, options)
end
|
.display(obj, options = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/iruby/display.rb', line 8
def display(obj, options = {})
obj = convert(obj, options)
options = obj.options
obj = obj.object
fuzzy_mime = options[:format] raise 'Invalid argument :format' unless !fuzzy_mime || String === fuzzy_mime
if exact_mime = options[:mime]
raise 'Invalid argument :mime' unless String === exact_mime
raise 'Invalid mime type' unless exact_mime.include?('/')
end
data = {}
render(data, obj, exact_mime, fuzzy_mime)
render(data, obj, 'text/plain', nil) unless data['text/plain']
data[exact_mime] = protect(exact_mime, obj) if exact_mime && !data.any? {|m,_| exact_mime == m }
data
end
|