Class: Servel::Entry
- Inherits:
-
Object
- Object
- Servel::Entry
- Extended by:
- Instrumentation
- Defined in:
- lib/servel/entry.rb
Instance Attribute Summary collapse
-
#ftype ⇒ Object
readonly
Returns the value of attribute ftype.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#listing_classes ⇒ Object
readonly
Returns the value of attribute listing_classes.
-
#media_type ⇒ Object
readonly
Returns the value of attribute media_type.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #as_json ⇒ Object
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil) ⇒ Entry
constructor
A new instance of Entry.
- #media? ⇒ Boolean
Methods included from Instrumentation
Constructor Details
#initialize(ftype:, type:, media_type: nil, listing_classes:, icon:, href:, name:, size: nil, mtime: nil) ⇒ Entry
Returns a new instance of Entry.
6 7 8 9 10 11 12 13 14 15 16 |
# 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 |
Instance Attribute Details
#ftype ⇒ Object (readonly)
Returns the value of attribute ftype.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def ftype @ftype end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def icon @icon end |
#listing_classes ⇒ Object (readonly)
Returns the value of attribute listing_classes.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def listing_classes @listing_classes end |
#media_type ⇒ Object (readonly)
Returns the value of attribute media_type.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def media_type @media_type end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def mtime @mtime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def size @size end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/servel/entry.rb', line 4 def type @type end |
Instance Method Details
#as_json ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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? ? "-" : @size, mtime: @mtime.to_i, mtimeText: @mtime.nil? ? "-" : @mtime.strftime("%e %b %Y %l:%M %p"), media: media? } end |
#directory? ⇒ Boolean
18 19 20 |
# File 'lib/servel/entry.rb', line 18 def directory? @ftype == :directory end |
#file? ⇒ Boolean
22 23 24 |
# File 'lib/servel/entry.rb', line 22 def file? @ftype == :file end |
#media? ⇒ Boolean
26 27 28 |
# File 'lib/servel/entry.rb', line 26 def media? !@media_type.nil? end |