Class: Spellr::File
- Inherits:
-
Pathname
- Object
- Pathname
- Spellr::File
- Defined in:
- lib/spellr/file.rb
Class Method Summary collapse
Instance Method Summary collapse
- #first_line ⇒ Object
- #hashbang ⇒ Object
- #insert(string, range) ⇒ Object
- #read_write ⇒ Object
- #relative_path ⇒ Object
Class Method Details
Instance Method Details
#first_line ⇒ Object
20 21 22 |
# File 'lib/spellr/file.rb', line 20 def first_line @first_line ||= each_line.first end |
#hashbang ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/spellr/file.rb', line 11 def hashbang @hashbang ||= begin return if extname != '' return unless first_line&.start_with?('#!') first_line end end |
#insert(string, range) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/spellr/file.rb', line 28 def insert(string, range) read_write do |body| body[range] = string body end end |
#read_write ⇒ Object
35 36 37 |
# File 'lib/spellr/file.rb', line 35 def read_write write(yield read) end |