Class: AwesomePrint::Formatters::ClassFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/awesome_print/formatters/class_formatter.rb

Constant Summary

Constants inherited from BaseFormatter

BaseFormatter::DEFAULT_LIMIT_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFormatter

#align, #get_limit_size, #indent, #indentation, #indented, #limited, #method_tuple, #outdent, #should_be_limited?

Methods included from Colorize

#colorize

Constructor Details

#initialize(klass, inspector) ⇒ ClassFormatter

Returns a new instance of ClassFormatter.



9
10
11
12
13
# File 'lib/awesome_print/formatters/class_formatter.rb', line 9

def initialize(klass, inspector)
  @klass = klass
  @inspector = inspector
  @options = inspector.options
end

Instance Attribute Details

#inspectorObject (readonly)

Returns the value of attribute inspector.



7
8
9
# File 'lib/awesome_print/formatters/class_formatter.rb', line 7

def inspector
  @inspector
end

#klassObject (readonly)

Returns the value of attribute klass.



7
8
9
# File 'lib/awesome_print/formatters/class_formatter.rb', line 7

def klass
  @klass
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/awesome_print/formatters/class_formatter.rb', line 7

def options
  @options
end

Instance Method Details

#formatObject



15
16
17
18
19
20
21
22
# File 'lib/awesome_print/formatters/class_formatter.rb', line 15

def format
  superclass = klass.superclass
  if superclass
    colorize("#{klass.inspect} < #{superclass}", :class)
  else
    colorize(klass.inspect, :class)
  end
end