Class: PowerAssert::SafeInspectable (Ruby 2.7.5)
Description: Class : PowerAssert::SafeInspectable - Ruby 2.7.5

### Home Classes Methods

### In Files

- power_assert-1.1.7/lib/power_assert/inspector.rb

### Parent

Object

### Methods

- ::new
- #inspect

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- PowerAssert
- PowerAssert::BlockContext
- PowerAssert::Configuration
- PowerAssert::Context
- PowerAssert::Empty
- PowerAssert::Formatter
- PowerAssert::InspectedValue
- PowerAssert::Parser
- PowerAssert::Parser::Branch
- PowerAssert::Parser::DummyParser
- PowerAssert::SafeInspectable
- PowerAssert::TraceContext

No matching classes.

# PowerAssert::SafeInspectable

### Public Class Methods

new(value) click to toggle source

                   # File power_assert-1.1.7/lib/power_assert/inspector.rb, line 16
    def initialize(value)
      @value = value
    end

### Public Instance Methods

inspect() click to toggle source

                   # File power_assert-1.1.7/lib/power_assert/inspector.rb, line 20
    def inspect
      inspected = @value.inspect
      if Encoding.compatible?(Encoding.default_external, inspected)
        inspected
      else
        begin
          "#{inspected.encode(Encoding.default_external)}(#{inspected.encoding})"
        rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
          inspected.force_encoding(Encoding.default_external)
        end
      end
    rescue => e
      "InspectionFailure: #{e.class}: #{e.message.each_line.first}"
    end