Class: Alula::Storage::FileItem

Inherits:
Item
  • Object
show all
Defined in:
lib/alula/storages/file_item.rb

Instance Attribute Summary

Attributes inherited from Item

#name

Instance Method Summary collapse

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

Returns:

  • (Boolean)


11
12
13
# File 'lib/alula/storages/file_item.rb', line 11

def exists?
  ::File.file?(@file)
end

#extensionObject



15
16
17
# File 'lib/alula/storages/file_item.rb', line 15

def extension
  ::File.extname(@file)[1..-1]
end

#filepathObject



19
20
21
# File 'lib/alula/storages/file_item.rb', line 19

def filepath
  @file
end

#has_payload?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/alula/storages/file_item.rb', line 23

def has_payload?
  ::File.read(@file, 3) == "---"
end

#mtimeObject



31
32
33
# File 'lib/alula/storages/file_item.rb', line 31

def mtime
  ::File.mtime(@file)
end

#openObject



39
40
41
# File 'lib/alula/storages/file_item.rb', line 39

def open
  ::File.open(@file)
end

#readObject



35
36
37
# File 'lib/alula/storages/file_item.rb', line 35

def read
  ::File.read(@file)
end

#sizeObject



27
28
29
# File 'lib/alula/storages/file_item.rb', line 27

def size
  ::File.size(@file)
end