/ Published in: Ruby
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
# 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
Comments
 Subscribe to comments
                    Subscribe to comments
                
                