Sha256: ca803a0392b1934b8fd8b861dc8b2da67d74dc772c49a5c373f7619908836343

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

module Terrestrial
  module InspectionString
    def inspect
      original_inspect_string = super
      # this is kind of a silly way of getting the object id hex string but
      # multiple Ruby versions have changed how this calculated.
      hex_object_id = /#{self.class.to_s}:0x([0-9a-f]+)/.match(original_inspect_string)[1]

      (
        ["\#<#{self.class.to_s}:0x#{hex_object_id}"] +
        inspectable_properties.map { |name|
          [
            name,
            instance_variable_get("@#{name}").inspect
          ].join("=")
        }
      ).join(" ") + ">"
    end

    private def inspectable_properties
      []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
terrestrial-0.5.0 lib/terrestrial/inspection_string.rb