Class: AwesomePrint

Inherits:
Object show all
Defined in:
lib/ap/awesome_print.rb

Constant Summary collapse

AP =
:__awesome_print__
CORE =
[ :array, :hash, :class, :file, :dir, :bigdecimal, :rational, :struct, :method, :unboundmethod ]
@@force_colors =
false

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AwesomePrint

Returns a new instance of AwesomePrint.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ap/awesome_print.rb', line 14

def initialize(options = {})
  @options = { 
    :multiline => true,           # Display in multiple lines.
    :plain     => false,          # Use colors.
    :indent    => 4,              # Indent using 4 spaces.
    :index     => true,           # Display array indices.
    :html      => false,          # Use ANSI color codes rather than HTML.
    :sorted_hash_keys => false,   # Do not sort hash keys.
    :color     => { 
      :array      => :white,
      :bigdecimal => :blue,
      :class      => :yellow,
      :date       => :greenish,
      :falseclass => :red,
      :fixnum     => :blue,
      :float      => :blue,
      :hash       => :pale,
      :struct     => :pale,
      :nilclass   => :red,
      :string     => :yellowish,
      :symbol     => :cyanish,
      :time       => :greenish,
      :trueclass  => :green,
      :method     => :purpleish,
      :args       => :pale
    }
  }

  # Merge custom defaults and let explicit options parameter override them.
  merge_custom_defaults!
  merge_options!(options)

  @indentation = @options[:indent].abs
  Thread.current[AP] ||= []
end