Class: AwesomeDump

Inherits:
Object
  • Object
show all
Defined in:
lib/ad/awesome_dump.rb

Defined Under Namespace

Modules: Util Classes: Formatter

Constant Summary collapse

AD =
:__awesome_dump__

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AwesomeDump

Returns a new instance of AwesomeDump.



11
12
13
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
# File 'lib/ad/awesome_dump.rb', line 11

def initialize(options = {})
  @options = { 
    :multiline => true,
    :plain     => false,
    :indent    => 4,
    :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
    }
  }
  
  # Merge custom defaults and let explicit options parameter override them.
  merge_custom_defaults!
  merge_options!(options)
  
  @indentation = @options[:indent].abs
  Thread.current[AD] ||= []
  
  @formatter = Formatter.new(self.method(:awesome), @options)
  
  extend Util
end