class Linguist::Blob
‘data`, `path` and `size`.
like a Grit::Blob. It provides the basic interface: `name`,
A Blob is a wrapper around the content of a file to make it quack
def data
Public: File contents.
def data @content end
def extension
Public: Get file extension.
def extension extensions.last || "" end
def extensions
=> [".html.erb", ".erb"]
>> Linguist::Blob.new("app/views/things/index.html.erb").extensions
Public: Return an array of the file extensions
def extensions _, *segments = name.downcase.split(".", -1) segments.map.with_index do |segment, index| "." + segments[index..-1].join(".") end end
def initialize(path, content, symlink: false)
symlink - Whether the file is a symlink.
content - Content of the file.
path - A path String (does not necessarily exists on the file system).
Public: Initialize a new Blob.
def initialize(path, content, symlink: false) @path = path @content = content @symlink = symlink end
def name
Public: File name
def name File.basename(@path) end
def size
Public: Get byte size
def size @content.bytesize end
def symlink?
Public: Is this a symlink?
def symlink? @symlink end