class Servel::Entry
Attributes
ftype[R]
href[R]
icon[R]
listing_classes[R]
media_type[R]
mtime[R]
name[R]
size[R]
type[R]
Public Class Methods
new(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil)
click to toggle source
# File lib/servel/entry.rb, line 6 def initialize(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil) @ftype = ftype @type = type @media_type = media_type @listing_classes = listing_classes @icon = icon @href = href @name = name @size = size @mtime = mtime end
Public Instance Methods
as_json(*)
click to toggle source
# File lib/servel/entry.rb, line 30 def as_json(*) { icon: @icon, href: Rack::Utils.escape_path(@href), class: @listing_classes, mediaType: @media_type, name: @name, type: @type, size: @size.to_i, sizeText: @size.nil? ? "-" : ActiveSupport::NumberHelper.number_to_human_size(@size), mtime: @mtime.to_i, mtimeText: @mtime.nil? ? "-" : @mtime.strftime("%e %b %Y %l:%M %p"), media: media? } end
directory?()
click to toggle source
# File lib/servel/entry.rb, line 18 def directory? @ftype == :directory end
file?()
click to toggle source
# File lib/servel/entry.rb, line 22 def file? @ftype == :file end
media?()
click to toggle source
# File lib/servel/entry.rb, line 26 def media? !@media_type.nil? end