Module: Pry::CodeObject::Helpers
- Included in:
- Pry::Command, Method, WrappedModule, WrappedModule::Candidate
- Defined in:
- lib/pry/code_object.rb
Instance Method Summary collapse
- #c_method? ⇒ Boolean
-
#c_module? ⇒ Boolean
‘true` if this module was defined by means of the C API, `false` if it’s a Ruby module.
- #command? ⇒ Boolean
- #module_with_yard_docs? ⇒ Boolean
-
#real_method_object? ⇒ Boolean
we need this helper as some Pry::Method objects can wrap Procs.
Instance Method Details
#c_method? ⇒ Boolean
28 29 30 |
# File 'lib/pry/code_object.rb', line 28 def c_method? real_method_object? && source_type == :c end |
#c_module? ⇒ Boolean
Note:
If a module defined by C was extended with a lot of methods written in Ruby, this method would fail.
Returns ‘true` if this module was defined by means of the C API, `false` if it’s a Ruby module.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pry/code_object.rb', line 44 def c_module? if is_a?(WrappedModule) method_locations = wrapped.methods(false).map do |m| wrapped.method(m).source_location end method_locations.concat(wrapped.instance_methods(false).map do |m| wrapped.instance_method(m).source_location end) c_methods = method_locations.grep(nil).count ruby_methods = method_locations.count - c_methods c_methods > ruby_methods end end |
#command? ⇒ Boolean
36 37 38 |
# File 'lib/pry/code_object.rb', line 36 def command? is_a?(Module) && self <= Pry::Command end |
#module_with_yard_docs? ⇒ Boolean
32 33 34 |
# File 'lib/pry/code_object.rb', line 32 def module_with_yard_docs? is_a?(WrappedModule) && yard_docs? end |
#real_method_object? ⇒ Boolean
we need this helper as some Pry::Method objects can wrap Procs
24 25 26 |
# File 'lib/pry/code_object.rb', line 24 def real_method_object? is_a?(::Method) || is_a?(::UnboundMethod) end |