class Thoth::Media

Public Instance Methods

created_at(format = nil) click to toggle source

Gets the creation time of this file. If format is provided, the time will be returned as a formatted String. See Time.strftime for details.

# File lib/thoth/model/media.rb, line 47
def created_at(format = nil)
  if new?
    format ? Time.now.strftime(format) : Time.now
  else
    format ? self[:created_at].strftime(format) : self[:created_at]
  end
end
filename=(filename) click to toggle source
# File lib/thoth/model/media.rb, line 55
def filename=(filename)
  self[:filename] = filename.strip unless filename.nil?
end
path() click to toggle source

Gets the absolute path to this file.

# File lib/thoth/model/media.rb, line 60
def path
  File.join(Config.media, filename[0].chr.downcase, filename)
end
size() click to toggle source
# File lib/thoth/model/media.rb, line 64
def size
  return self[:size] unless self[:size] == 0 && File.exist?(path)

  self[:size] = File.size(path)
  save
  self[:size]
end
updated_at(format = nil) click to toggle source

Gets the time this file was last updated. If format is provided, the time will be returned as a formatted String. See Time.strftime for details.

# File lib/thoth/model/media.rb, line 74
def updated_at(format = nil)
  if new?
    format ? Time.now.strftime(format) : Time.now
  else
    format ? self[:updated_at].strftime(format) : self[:updated_at]
  end
end
url() click to toggle source

URL for this file.

# File lib/thoth/model/media.rb, line 83
def url
  Config.site['url'].chomp('/') + MediaController.r(:/, filename).to_s
end