Class: IRuby::Display::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/iruby/display.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match, mime, render, priority) ⇒ Renderer

Returns a new instance of Renderer.



257
258
259
260
261
262
# File 'lib/iruby/display.rb', line 257

def initialize(match, mime, render, priority)
  @match = match
  @mime = mime
  @render = render
  @priority = priority
end

Instance Attribute Details

#matchObject (readonly)

Returns the value of attribute match.



255
256
257
# File 'lib/iruby/display.rb', line 255

def match
  @match
end

#mimeObject (readonly)

Returns the value of attribute mime.



255
256
257
# File 'lib/iruby/display.rb', line 255

def mime
  @mime
end

#priorityObject (readonly)

Returns the value of attribute priority.



255
256
257
# File 'lib/iruby/display.rb', line 255

def priority
  @priority
end

Instance Method Details

#match?(obj) ⇒ Boolean

Returns:

  • (Boolean)


264
265
266
# File 'lib/iruby/display.rb', line 264

def match?(obj)
  @match.call(obj)
end

#render(obj) ⇒ Object



268
269
270
271
# File 'lib/iruby/display.rb', line 268

def render(obj)
  result = @render.call(obj)
  Array === result ? result : [@mime, result]
end