Guest User

Untitled

a guest
Feb 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. def line_at_pos(pos, string)
  2. pos = string.length + pos if pos < 0
  3. pos = 0 if pos < 0
  4. l = (string.rindex(/[\r\n]/, pos) || -1) + 1
  5. r = (string.index(/[\r\n]/, pos) || string.length) - 1
  6. string[l..r]
  7. end
Add Comment
Please, Sign In to add comment