class Parsby::Backup

Public Instance Methods

all() click to toggle source
# File lib/parsby.rb, line 385
def all
  with_saved_pos do
    seek 0
    read
  end
end
back(n = back_size) click to toggle source
# File lib/parsby.rb, line 394
def back(n = back_size)
  with_saved_pos do |saved|
    seek -n, IO::SEEK_CUR
    read n
  end
end
back_lines() click to toggle source
# File lib/parsby.rb, line 407
def back_lines
  (back + rest_of_line).lines
end
col() click to toggle source
# File lib/parsby.rb, line 411
def col
  back[/(?<=\A|\n).*\z/].length
end
current_line() click to toggle source
# File lib/parsby.rb, line 415
def current_line
  with_saved_pos do
    seek(-col, IO::SEEK_CUR)
    readline.chomp
  end
end
rest_of_line() click to toggle source
# File lib/parsby.rb, line 401
def rest_of_line
  with_saved_pos { readline }
rescue EOFError
  ""
end
with_saved_pos(&b) click to toggle source
# File lib/parsby.rb, line 378
def with_saved_pos(&b)
  saved = pos
  b.call saved
ensure
  seek saved
end