Return to Snippet

Revision: 32399
at September 23, 2010 17:30 by rkumar


Initial Code
# given a line and a cursor position returns the word
# under the cursor. Takes only spaces into account, not punctuation
# characters.
    def _get_word_under_cursor line, pos
      finish = line.index(" ", pos)
      start = line.rindex(" ",pos)
      finish = -1 if finish.nil?
      start = 0 if start.nil?
      return line[start..finish]
    end

Initial URL


Initial Description


Initial Title
get word under cursor

Initial Tags
ruby

Initial Language
Ruby