Sha256: dec93acac7fe7647ef6d20a444809c8b12ebf613e5f84a28a52fbc6a45889011

Contents?: true

Size: 1.34 KB

Versions: 22

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

# Object
class Object
  def self.grep_method(search, all = true)
    search = search.to_sym unless search.is_a? Regexp
    methods(all).grep search
  end

  # grep public instance method
  #
  # === Example
  #
  # target class
  #
  #   class GrepMethod
  #     def self.public_method1;end
  #     def self.public_method2;end
  #     def self.public_method11;end
  #     protected
  #     def self.protected_method1;end
  #     def self.protected_method2;end
  #     def self.protected_method11;end
  #     private
  #     def self.private_method1;end
  #     def self.private_method2;end
  #     def self.private_method11;end
  #   end
  #
  #  method call
  #
  #   GrepMethod.new.grep_method :public_method1, false # => [:public_method1]
  #   GrepMethod.grep_method :public_method1, false # => [:public_method1]
  #   GrepMethod.new.grep_method /public_method1/, false # => [:public_method1, :public_method11]
  #   GrepMethod.grep_method /public_method1/, false # => [:public_method1, :public_method11]
  #   GrepMethod.new.grep_method /public_method3/, false # => []
  #   GrepMethod.grep_method /public_method3/, false # => []
  #   GrepMethod.new.grep_method :__send__, true # => [:__send__]
  #   GrepMethod.grep_method :__send__, true # => [:__send__]
  #
  def grep_method(search, all = true)
    self.class.grep_method(search, all)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.150 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.149 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.148 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.147 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.146 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.145 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.144 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.143 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.142 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.141 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.140 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.139 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.138 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.137 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.136 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.135 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.134 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.133 lib/open_classes/object/grep_method.rb
tbpgr_utils-0.0.132 lib/open_classes/object/grep_method.rb