Module: IRuby::Display::Registry

Extended by:
Registry
Included in:
Registry
Defined in:
lib/iruby/display.rb

Instance Method Summary collapse

Instance Method Details

#format(mime = nil, &block) ⇒ Object



304
305
306
307
308
309
310
311
312
313
# File 'lib/iruby/display.rb', line 304

def format(mime = nil, &block)
  renderer << Renderer.new(@match, mime, block, @priority)
  renderer.sort_by! { |r| -r.priority }

  # Decrease priority implicitly for all formats
  # which are added later for a type.
  # Overwrite with the `priority` method!
  @priority -= 1
  nil
end

#match(&block) ⇒ Object



281
282
283
284
285
# File 'lib/iruby/display.rb', line 281

def match(&block)
  @match = FormatMatcher.new(&block)
  priority 0
  nil
end

#priority(p) ⇒ Object



299
300
301
302
# File 'lib/iruby/display.rb', line 299

def priority(p)
  @priority = p
  nil
end

#rendererObject



277
278
279
# File 'lib/iruby/display.rb', line 277

def renderer
  @renderer ||= []
end

#respond_to(name) ⇒ Object



287
288
289
290
291
# File 'lib/iruby/display.rb', line 287

def respond_to(name)
  @match = RespondToFormatMatcher.new(name)
  priority 0
  nil
end

#type(&block) ⇒ Object



293
294
295
296
297
# File 'lib/iruby/display.rb', line 293

def type(&block)
  @match = TypeFormatMatcher.new(block)
  priority 0
  nil
end