Sha256: fe12e7911a93168736043d1da6e3ec994fe528d1bfcca60e1867b9995ac6d408

Contents?: true

Size: 651 Bytes

Versions: 4

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

module Scryglass
  module LensHelper
    def method_showcase_for(object)
      method_list = object.methods - Object.methods
      label_space = [method_list.map(&:length).max, 45].min
      method_list.sort.map do |method_name|
        label = method_name.to_s.ljust(label_space, ' ')
        begin
          method = object.method(method_name)
          label + '  :  ' +
            method.source_location.to_a.join(':') + "\n" +
            Hexes.capture_io { puts method.source }
        rescue => e
          label + '  :  Error: ' +
            e.message + "\n"
        end
      end.join("\n")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
scryglass-1.1.0 lib/scryglass/lens_helper.rb
scryglass-1.0.1 lib/scryglass/lens_helper.rb
scryglass-1.0.0 lib/scryglass/lens_helper.rb
scryglass-0.1.0 lib/scryglass/lens_helper.rb