Class: FileLike

Inherits:
Object
  • Object
show all
Defined in:
app/models/file_like.rb

Overview

Base class for Github API files and mock files that perform basic operations on the blob and path

Direct Known Subclasses

StubFile

Instance Method Summary collapse

Instance Method Details

#basename(ext = nil) ⇒ Object



8
9
10
# File 'app/models/file_like.rb', line 8

def basename(ext = nil)
  File.basename path, ext
end

#extnameObject



4
5
6
# File 'app/models/file_like.rb', line 4

def extname
  File.extname(path).gsub(/^\./, '') # without leading .
end

#first_line_of_patchObject



12
13
14
# File 'app/models/file_like.rb', line 12

def first_line_of_patch
  patch.changed_lines.first.try(:number)
end