class Linguist::Blob
A Blob is a wrapper around the content of a file to make it quack like a Grit::Blob. It provides the basic interface: `name`, `data`, `path` and `size`.
Attributes
path[R]
Public: Filename
Examples
Blob.new("/path/to/linguist/lib/linguist.rb", "").path # => "/path/to/linguist/lib/linguist.rb"
Returns a String
Public Class Methods
Public Instance Methods
data()
click to toggle source
Public: File contents.
Returns a String.
# File lib/linguist/blob.rb, line 41 def data @content end
extension()
click to toggle source
Public: Get file extension.
Returns a String.
# File lib/linguist/blob.rb, line 55 def extension extensions.last || "" end
extensions()
click to toggle source
Public: Return an array of the file extensions
>> Linguist::Blob.new("app/views/things/index.html.erb").extensions => [".html.erb", ".erb"]
Returns an Array
# File lib/linguist/blob.rb, line 65 def extensions _, *segments = name.downcase.split(".", -1) segments.map.with_index do |segment, index| "." + segments[index..-1].join(".") end end
name()
click to toggle source
Public: File name
Returns a String
# File lib/linguist/blob.rb, line 34 def name File.basename(@path) end
size()
click to toggle source
Public: Get byte size
Returns an Integer.
# File lib/linguist/blob.rb, line 48 def size @content.bytesize end