class Artifact::ReadableFile

Attributes

full_path[R]
path[R]

Public Class Methods

new(path) click to toggle source
# File lib/artifact.rb, line 267
def initialize(path)
  if path[Artifact.root] # path contains root, meaning absolute path
    @path      = Artifact.relative_path(path)
    @full_path = path
  else
    @path      = path
    @full_path = Artifact.full_path(path)
  end
end

Public Instance Methods

body() click to toggle source
# File lib/artifact.rb, line 293
def body
  @content
end
dirname() click to toggle source
# File lib/artifact.rb, line 285
def dirname
  File.dirname(full_path)
end
exists?() click to toggle source
# File lib/artifact.rb, line 301
def exists?
  File.exist?(full_path)
end
filename() click to toggle source
# File lib/artifact.rb, line 277
def filename
  File.basename(path)
end
last_modified() click to toggle source
# File lib/artifact.rb, line 289
def last_modified
  File.mtime(full_path)
end
meta() click to toggle source
# File lib/artifact.rb, line 297
def meta
  {}
end
slug() click to toggle source
# File lib/artifact.rb, line 281
def slug
  File.basename(path, File.extname(path))
end

Private Instance Methods

<=>(other_file) click to toggle source
# File lib/artifact.rb, line 315
def <=>(other_file)
  self.last_modified <=> other_file.last_modified
end
content() click to toggle source
# File lib/artifact.rb, line 307
def content
  @content ||= read
end
read() click to toggle source
# File lib/artifact.rb, line 311
def read
  IO.read(@full_path)
end