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
don’t use FastIgnore shebang handling because i use lots of different FastIgnore instances and each would to open the files.
- #insert(string, range) ⇒ Object
- #read_write ⇒ Object
- #relative_path ⇒ Object
Class Method Details
.wrap(file) ⇒ Object
7 8 9 |
# File 'lib/spellr/file.rb', line 7 def self.wrap(file) file.is_a?(Spellr::File) ? file : Spellr::File.new(file) end |
Instance Method Details
#first_line ⇒ Object
22 23 24 |
# File 'lib/spellr/file.rb', line 22 def first_line @first_line ||= each_line.first end |
#hashbang ⇒ Object
don’t use FastIgnore shebang handling because i use lots of different FastIgnore instances and each would to open the files.
13 14 15 16 17 18 19 20 |
# File 'lib/spellr/file.rb', line 13 def hashbang @hashbang ||= begin return if extname != '' return unless first_line&.start_with?('#!') first_line end end |
#insert(string, range) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/spellr/file.rb', line 30 def insert(string, range) read_write do |body| body[range] = string body end end |
#read_write ⇒ Object
37 38 39 |
# File 'lib/spellr/file.rb', line 37 def read_write write(yield read) end |
#relative_path ⇒ Object
26 27 28 |
# File 'lib/spellr/file.rb', line 26 def relative_path @relative_path ||= relative_path_from(Spellr.pwd) end |