Class: AmazingPrint::Formatters::ArrayFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/amazing_print/formatters/array_formatter.rb

Constant Summary

Constants inherited from BaseFormatter

BaseFormatter::DEFAULT_LIMIT_SIZE, BaseFormatter::INDENT_CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFormatter

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

Methods included from Colorize

#colorize

Constructor Details

#initialize(array, inspector) ⇒ ArrayFormatter

Returns a new instance of ArrayFormatter.



10
11
12
13
14
15
# File 'lib/amazing_print/formatters/array_formatter.rb', line 10

def initialize(array, inspector)
  super()
  @array = array
  @inspector = inspector
  @options = inspector.options
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



8
9
10
# File 'lib/amazing_print/formatters/array_formatter.rb', line 8

def array
  @array
end

#inspectorObject (readonly)

Returns the value of attribute inspector.



8
9
10
# File 'lib/amazing_print/formatters/array_formatter.rb', line 8

def inspector
  @inspector
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/amazing_print/formatters/array_formatter.rb', line 8

def options
  @options
end

Instance Method Details

#formatObject



17
18
19
20
21
22
23
24
25
# File 'lib/amazing_print/formatters/array_formatter.rb', line 17

def format
  if array.empty?
    '[]'
  elsif methods_array?
    methods_array
  else
    simple_array
  end
end