Class: WTF::Dumper

Inherits:
Object
  • Object
show all
Defined in:
lib/wtf/dumper.rb

Defined Under Namespace

Classes: Output

Constant Summary collapse

PREFIX_OPTIONS =
[:time, :nl, :np].freeze
FORMAT_OPTIONS =
[:pp, :yaml, :json, :text, :line, :csv].freeze
MODIFY_OPTIONS =
[:bare, :name].freeze
OUTPUT_OPTIONS =
[:puts, :error, :file].freeze
OPTIONS =
(PREFIX_OPTIONS + FORMAT_OPTIONS + MODIFY_OPTIONS + OUTPUT_OPTIONS).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Dumper

Returns a new instance of Dumper.



12
13
14
15
16
17
18
# File 'lib/wtf/dumper.rb', line 12

def initialize(*args)
  @args = args
  @options = {}
  while is_option?(args.last)
    @options[args.pop] = true
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



10
11
12
# File 'lib/wtf/dumper.rb', line 10

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/wtf/dumper.rb', line 10

def options
  @options
end

Instance Method Details

#callObject



20
21
22
23
24
# File 'lib/wtf/dumper.rb', line 20

def call
  where, names = parse_source(caller[1])
  data = prefix(where) << format(names)
  output(data)
end