Class: Foruiman::Diagnostics
- Inherits:
-
Object
- Object
- Foruiman::Diagnostics
- Defined in:
- lib/foruiman/diagnostics.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close ⇒ Object
- #error(exception) ⇒ Object
-
#initialize(interactive:, stderr: $stderr) ⇒ Diagnostics
constructor
A new instance of Diagnostics.
Constructor Details
#initialize(interactive:, stderr: $stderr) ⇒ Diagnostics
Returns a new instance of Diagnostics.
6 7 8 9 10 |
# File 'lib/foruiman/diagnostics.rb', line 6 def initialize(interactive:, stderr: $stderr) @interactive = interactive @temporary = nil @output = stderr end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/foruiman/diagnostics.rb', line 4 def path @path end |
Instance Method Details
#close ⇒ Object
24 25 26 |
# File 'lib/foruiman/diagnostics.rb', line 24 def close @temporary&.close end |
#error(exception) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/foruiman/diagnostics.rb', line 12 def error(exception) if @interactive && !@temporary require "tempfile" @temporary = Tempfile.create(["foruiman-", ".log"]) @temporary.chmod(0o600) @output = @temporary @path = @temporary.path end @output.puts(exception.(highlight: false)) @output.flush end |