Class: Artifact::ReadableFile

Inherits:
Object
  • Object
show all
Defined in:
lib/artifact.rb

Direct Known Subclasses

WritableFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ReadableFile

Returns a new instance of ReadableFile.



267
268
269
270
271
272
273
274
275
# 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

Instance Attribute Details

#full_pathObject (readonly)

Returns the value of attribute full_path.



265
266
267
# File 'lib/artifact.rb', line 265

def full_path
  @full_path
end

#pathObject (readonly)

Returns the value of attribute path.



265
266
267
# File 'lib/artifact.rb', line 265

def path
  @path
end

Instance Method Details

#bodyObject



293
294
295
# File 'lib/artifact.rb', line 293

def body
  @content
end

#dirnameObject



285
286
287
# File 'lib/artifact.rb', line 285

def dirname
  File.dirname(full_path)
end

#exists?Boolean

Returns:

  • (Boolean)


301
302
303
# File 'lib/artifact.rb', line 301

def exists?
  File.exist?(full_path)
end

#filenameObject



277
278
279
# File 'lib/artifact.rb', line 277

def filename
  File.basename(path)
end

#last_modifiedObject



289
290
291
# File 'lib/artifact.rb', line 289

def last_modified
  File.mtime(full_path)
end

#metaObject



297
298
299
# File 'lib/artifact.rb', line 297

def meta
  {}
end

#slugObject



281
282
283
# File 'lib/artifact.rb', line 281

def slug
  File.basename(path, File.extname(path))
end