Class: Replay

Inherits:
Object show all
Defined in:
lib/chitin/tools/replay.rb

Overview

The hard part is to not confuse interface with implementation. Tough because this relies almost entirely on the interface. Possibly reopen STDOUT so that it writes to two, instead of just redefining puts/print?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, session) ⇒ Replay



11
12
13
14
# File 'lib/chitin/tools/replay.rb', line 11

def initialize(path, session)
  @path = path
  @session = session
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/chitin/tools/replay.rb', line 8

def path
  @path
end

#sessionObject (readonly)

Returns the value of attribute session.



9
10
11
# File 'lib/chitin/tools/replay.rb', line 9

def session
  @session
end

Instance Method Details

#end!Object



20
21
22
23
24
25
# File 'lib/chitin/tools/replay.rb', line 20

def end!
  multi = session.out
  session.out = STDOUT
  stringio = multi.ios[1]
  @text = stringio.read
end

#start!Object



16
17
18
# File 'lib/chitin/tools/replay.rb', line 16

def start!
  session.out = MultiIO.new STDOUT, StringIO.new
end

#to_sObject



27
28
29
# File 'lib/chitin/tools/replay.rb', line 27

def to_s
  @text
end