Class: RubyFriendlyError::Utils
- Inherits:
-
Object
- Object
- RubyFriendlyError::Utils
- Defined in:
- lib/ruby_friendly_error/utils.rb
Class Method Summary collapse
Class Method Details
.replace_string_at(string, range) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/ruby_friendly_error/utils.rb', line 15 def replace_string_at string, range regexp = Regexp.new "\\A(.{#{range.first - 1}})(.{#{range.size}})(.*)\\Z" match_data = string.match regexp replaced_string = yield match_data[2] match_data[1] + replaced_string + match_data[3] end |
.suppress_error_display ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/ruby_friendly_error/utils.rb', line 6 def suppress_error_display original_stdout = $stderr $stderr = StringIO.new yield ensure $stderr = original_stdout end |