Class: IRuby::Display::TypeFormatMatcher

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

Instance Method Summary collapse

Methods inherited from FormatMatcher

#call

Constructor Details

#initialize(class_block) ⇒ TypeFormatMatcher

Returns a new instance of TypeFormatMatcher.



228
229
230
231
232
233
234
235
236
237
238
# File 'lib/iruby/display.rb', line 228

def initialize(class_block)
  super() do |obj|
    begin
      self.klass === obj
    # We have to rescue all exceptions since constant autoloading could fail with a different error
    rescue Exception
      false
    end
  end
  @class_block = class_block
end

Instance Method Details

#inspectObject



244
245
246
247
248
249
250
251
# File 'lib/iruby/display.rb', line 244

def inspect
  klass = begin
            @class_block.()
          rescue Exception
            @class_block
          end
  "#{self.class.name}[%p]" % klass
end

#klassObject



240
241
242
# File 'lib/iruby/display.rb', line 240

def klass
  @class_block.()
end