Class: Alula::Storage::FileItem
- Defined in:
- lib/alula/storages/file_item.rb
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #extension ⇒ Object
- #filepath ⇒ Object
- #has_payload? ⇒ Boolean
-
#initialize(opts) ⇒ FileItem
constructor
A new instance of FileItem.
- #mtime ⇒ Object
- #open ⇒ Object
- #read ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(opts) ⇒ FileItem
Returns a new instance of FileItem.
5 6 7 8 9 |
# File 'lib/alula/storages/file_item.rb', line 5 def initialize(opts) super @file = opts.delete(:file) end |
Instance Method Details
#exists? ⇒ Boolean
11 12 13 |
# File 'lib/alula/storages/file_item.rb', line 11 def exists? ::File.file?(@file) end |
#extension ⇒ Object
15 16 17 |
# File 'lib/alula/storages/file_item.rb', line 15 def extension ::File.extname(@file)[1..-1] end |
#filepath ⇒ Object
19 20 21 |
# File 'lib/alula/storages/file_item.rb', line 19 def filepath @file end |
#has_payload? ⇒ Boolean
23 24 25 |
# File 'lib/alula/storages/file_item.rb', line 23 def has_payload? ::File.read(@file, 3) == "---" end |
#mtime ⇒ Object
31 32 33 |
# File 'lib/alula/storages/file_item.rb', line 31 def mtime ::File.mtime(@file) end |
#open ⇒ Object
39 40 41 |
# File 'lib/alula/storages/file_item.rb', line 39 def open ::File.open(@file) end |
#read ⇒ Object
35 36 37 |
# File 'lib/alula/storages/file_item.rb', line 35 def read ::File.read(@file) end |
#size ⇒ Object
27 28 29 |
# File 'lib/alula/storages/file_item.rb', line 27 def size ::File.size(@file) end |