Sha256: 0aef820b8a03a3dab97588bfc32ee18337b5339399348d298b81bcffac527b7e

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

require 'active_support/core_ext/string/inflections'

module Pio
  # Introduces Class.inspect method
  module ClassInspector
    # rubocop:disable LineLength
    def inspect
      field_and_type = fields.each_with_object([]) do |each, result|
        next if each.name == :padding
        result << [each.name,
                   each.prototype.instance_variable_get(:@obj_class).name.demodulize.sub(/be$/, '').underscore]
      end
      signature = field_and_type.map { |field, type| "#{field}: #{type}" }.join(', ')
      "#{self}(#{signature})"
    end
    # rubocop:enable LineLength
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.2 lib/pio/class_inspector.rb