Class: Spellr::Output

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

Direct Known Subclasses

OutputStubbed

Instance Method Summary collapse

Instance Method Details

#<<(other) ⇒ Object



53
54
55
56
57
58
# File 'lib/spellr/output.rb', line 53

def <<(other)
  self.exit_code = other.exit_code
  warn other.stderr.string if other.stderr?
  puts other.stdout.string if other.stdout?
  counts.merge!(other.counts) { |_k, a, b| a + b }
end

#countsObject



29
30
31
# File 'lib/spellr/output.rb', line 29

def counts
  @counts ||= Hash.new(0)
end

#exit_codeObject



5
6
7
# File 'lib/spellr/output.rb', line 5

def exit_code
  @exit_code ||= 0
end

#exit_code=(value) ⇒ Object



33
34
35
# File 'lib/spellr/output.rb', line 33

def exit_code=(value)
  @exit_code = value unless value.zero?
end

#increment(counter) ⇒ Object



37
38
39
# File 'lib/spellr/output.rb', line 37

def increment(counter)
  counts[counter] += 1
end


49
50
51
# File 'lib/spellr/output.rb', line 49

def print(str)
  stdout.print(str)
end

#puts(str) ⇒ Object



41
42
43
# File 'lib/spellr/output.rb', line 41

def puts(str)
  stdout.puts(str)
end

#stderrObject



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

def stderr
  @stderr ||= $stderr
end

#stderr?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/spellr/output.rb', line 25

def stderr?
  defined?(@stderr)
end

#stdinObject



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

def stdin
  @stdin ||= $stdin
end

#stdoutObject



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

def stdout
  @stdout ||= $stdout
end

#stdout?Boolean

Returns:

  • (Boolean)


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

def stdout?
  defined?(@stdout)
end

#warn(str) ⇒ Object



45
46
47
# File 'lib/spellr/output.rb', line 45

def warn(str)
  stderr.puts(str)
end