Class: RBON::Dump

Inherits:
Object
  • Object
show all
Defined in:
lib/rbon/dump.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(tab: ' ') ⇒ Dump

Returns a new instance of Dump.



6
7
8
# File 'lib/rbon/dump.rb', line 6

def initialize(tab:'  ')
  @tab, @io = tab, nil
end

Instance Method Details

#dump(object, io: StringIO.new) ⇒ Object Also known as: pretty_generate



10
11
12
13
14
15
# File 'lib/rbon/dump.rb', line 10

def dump(object, io:StringIO.new)
  @io = io
  traverse(object,'')
  @io.print "\n"
  @io.respond_to?(:string)? @io.string : nil
end