Class: Spellr::File
- Inherits:
-
Pathname
- Object
- Pathname
- Spellr::File
- Defined in:
- lib/spellr/file.rb
Instance Method Summary collapse
-
#first_line ⇒ Object
the bulk of this method is copied from fast_ignore.
- #insert(string, range) ⇒ Object
- #read_write ⇒ Object
- #relative_path ⇒ Object
- #wordlists ⇒ Object
Instance Method Details
#first_line ⇒ Object
the bulk of this method is copied from fast_ignore
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spellr/file.rb', line 19 def first_line # rubocop:disable Metrics/MethodLength return @first_line if defined?(@first_line) @first_line = nil file = ::File.new(to_s) @first_line = file.sysread(25) @first_line += file.sysread(50) until @first_line.include?("\n") file.close @first_line rescue ::EOFError, ::SystemCallError # :nocov: file&.close # :nocov: @first_line end |
#insert(string, range) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/spellr/file.rb', line 11 def insert(string, range) read_write do |body| body[range] = string body end end |
#read_write ⇒ Object
36 37 38 |
# File 'lib/spellr/file.rb', line 36 def read_write write(yield read) end |