Class: Proc
- Inherits:
-
Object
- Object
- Proc
- Defined in:
- lib/proc_source.rb
Instance Method Summary collapse
Instance Method Details
#proc_source ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/proc_source.rb', line 5 def proc_source return @source if @source filepath, start_pos = source_location code = File.readlines(filepath)[(start_pos-1)..-1].join tokens = Ripper.lex(code).drop_while do |t| !proc_token?(t) end @source = " " * tokens[0][0][1].to_i while token = tokens.shift @source += token[2] break if valid_proc_source?(@source) end @source end |