class Mmmm::ObjectMethods

Public Class Methods

new(obj) click to toggle source
# File lib/mmmm/object_methods.rb, line 18
def initialize obj
  @obj = obj
end

Public Instance Methods

inspect() click to toggle source
# File lib/mmmm/object_methods.rb, line 22
def inspect
  group_by_inherited_and_file.
    map { |inh_file, flms| "#{inh_file[1].cyan} #{inh_file[0]}\n#{lm_in_string(flms)}" }.
    join("\n")
end

Private Instance Methods

file_line_method_arr() click to toggle source
# File lib/mmmm/object_methods.rb, line 30
def file_line_method_arr
  @obj.methods.each_with_object([]) do |m, rs|
    file_line = @obj.method(m).source_location
    rs << FileLineMethod.new(file_line, m, inherited?(m)) if file_line
  end
end
group_by_inherited_and_file() click to toggle source
# File lib/mmmm/object_methods.rb, line 48
def group_by_inherited_and_file
  grouped = file_line_method_arr.
    group_by{ |flm| [flm.inherited?.to_s, flm.file] }.
    sort_by{ |inh_f, _| inh_f }

  Hash[grouped]
end
inherited?(method) click to toggle source
# File lib/mmmm/object_methods.rb, line 37
def inherited? method
  not open_class_defined_methods.include? method
end
lm_in_string(flms) click to toggle source
# File lib/mmmm/object_methods.rb, line 56
def lm_in_string flms
  flms.
    map {|flm| "#{format('%5d', flm.line)} #{flm.method}" }.
    join("\n")
end
open_class_defined_methods() click to toggle source
# File lib/mmmm/object_methods.rb, line 41
def open_class_defined_methods
  @ocdm ||= [:singleton_class, :class].
    map{ |klass| @obj.send(klass).instance_methods(false) }.
    flatten.
    uniq
end