Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created March 31, 2020 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/210cb16f163ddfd1de71f7ad0ff8ec59 to your computer and use it in GitHub Desktop.
Save havenwood/210cb16f163ddfd1de71f7ad0ff8ec59 to your computer and use it in GitHub Desktop.
class Window < IO
SEEK_LINE = 2
def self.for_fd(...)
super(...).tap { _1.seek SEEK_LINE }
end
end
example_io = File.open 'example.io'
window = Window.for_fd example_io.fileno
window.readline
#=> "Second line ..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment