Module: MethodSource::MethodExtensions
- Included in:
- Method, Proc, UnboundMethod
- Defined in:
- lib/method_source.rb
Overview
This module is to be included by ‘Method` and `UnboundMethod` and provides the `#source` functionality
Instance Method Summary collapse
-
#comment ⇒ String
Return the comments associated with the method as a string.
-
#source ⇒ String
Return the sourcecode for the method as a string (This functionality is only supported in Ruby 1.9 and above).
Instance Method Details
#comment ⇒ String
Return the comments associated with the method as a string. (This functionality is only supported in Ruby 1.9 and above)
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/method_source.rb', line 106 def comment if respond_to?(:source_location) comment = MethodSource.comment_helper(source_location) raise "Cannot locate source for this method: #{name}" if !comment else raise "Method#comment not supported by this Ruby version (#{RUBY_VERSION})" end comment end |
#source ⇒ String
Return the sourcecode for the method as a string (This functionality is only supported in Ruby 1.9 and above)
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/method_source.rb', line 87 def source if respond_to?(:source_location) source = MethodSource.source_helper(source_location) raise "Cannot locate source for this method: #{name}" if !source else raise "Method#source not supported by this Ruby version (#{RUBY_VERSION})" end source end |