Method: Decode::Language::Ruby::Definition#text
- Defined in:
- lib/decode/language/ruby/definition.rb
#text ⇒ Object
The source code associated with the definition.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/decode/language/ruby/definition.rb', line 59 def text location = @node.location source_text = location.slice_lines lines = source_text.split("\n") if lines.count == 1 return lines.first else # Get the indentation from the first line of the node in the original source if indentation = source_text[/\A\s+/] # Remove the base indentation from all lines lines.each{|line| line.sub!(indentation, "")} end return lines.join("\n") end end |