Class: Spellr::OutputStubbed

Inherits:
Output
  • Object
show all
Defined in:
lib/spellr/output_stubbed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Output

#<<, #counts, #increment, #print, #puts, #stderr?, #stdout?, #warn

Constructor Details

#initializeOutputStubbed

Returns a new instance of OutputStubbed.



9
10
11
# File 'lib/spellr/output_stubbed.rb', line 9

def initialize
  @exit_code = 0
end

Instance Attribute Details

#exit_codeObject

Returns the value of attribute exit_code.



7
8
9
# File 'lib/spellr/output_stubbed.rb', line 7

def exit_code
  @exit_code
end

Instance Method Details

#marshal_dumpObject

rubocop:disable Metrics/MethodLength



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/spellr/output_stubbed.rb', line 25

def marshal_dump # rubocop:disable Metrics/MethodLength
  {
    exit_code: exit_code,
    counts: @counts,
    stdin: @stdin&.string,
    stdin_pos: @stdin&.pos,
    stdout: @stdout&.string,
    stdout_pos: @stdout&.pos,
    stderr: @stderr&.string,
    stderr_pos: @stderr&.pos
  }
end

#marshal_load(dumped) ⇒ Object

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/spellr/output_stubbed.rb', line 38

def marshal_load(dumped) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  if dumped[:stdin]
    @stdin = StringIO.new(dumped[:stdin])
    @stdin.pos = dumped[:stdin_pos]
  end

  if dumped[:stdout]
    @stdout = StringIO.new(dumped[:stdout])
    @stdout.pos = dumped[:stdout_pos]
  end

  if dumped[:stderr]
    @stderr = StringIO.new(dumped[:stderr])
    @stderr.pos = dumped[:stderr_pos]
  end

  @exit_code = dumped[:exit_code]
  @counts = dumped[:counts]
end

#stderrObject



21
22
23
# File 'lib/spellr/output_stubbed.rb', line 21

def stderr
  @stderr ||= StringIO.new
end

#stdinObject



13
14
15
# File 'lib/spellr/output_stubbed.rb', line 13

def stdin
  @stdin ||= StringIO.new
end

#stdoutObject



17
18
19
# File 'lib/spellr/output_stubbed.rb', line 17

def stdout
  @stdout ||= StringIO.new
end