Class: Spellr::Output
- Inherits:
-
Object
- Object
- Spellr::Output
- Defined in:
- lib/spellr/output.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #counts ⇒ Object
- #exit_code ⇒ Object
- #exit_code=(value) ⇒ Object
- #increment(counter) ⇒ Object
- #print(str) ⇒ Object
- #puts(str) ⇒ Object
- #stderr ⇒ Object
- #stderr? ⇒ Boolean
- #stdin ⇒ Object
- #stdout ⇒ Object
- #stdout? ⇒ Boolean
- #warn(str) ⇒ Object
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 |
#counts ⇒ Object
29 30 31 |
# File 'lib/spellr/output.rb', line 29 def counts @counts ||= Hash.new(0) end |
#exit_code ⇒ Object
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 |
#print(str) ⇒ Object
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 |
#stderr ⇒ Object
17 18 19 |
# File 'lib/spellr/output.rb', line 17 def stderr @stderr ||= $stderr end |
#stderr? ⇒ Boolean
25 26 27 |
# File 'lib/spellr/output.rb', line 25 def stderr? defined?(@stderr) end |
#stdin ⇒ Object
9 10 11 |
# File 'lib/spellr/output.rb', line 9 def stdin @stdin ||= $stdin end |
#stdout ⇒ Object
13 14 15 |
# File 'lib/spellr/output.rb', line 13 def stdout @stdout ||= $stdout end |
#stdout? ⇒ 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 |