class BitBroker::Metadata::FileInfo
Constants
- STATUS_REMOVED
describes file status
Attributes
mtime[R]
path[R]
size[R]
Public Class Methods
new(dirpath, filepath)
click to toggle source
# File lib/bitbroker/metadata.rb, line 88 def initialize(dirpath, filepath) @fpath = "#{dirpath}/#{filepath}" @path = filepath @status = 0 self.update end
Public Instance Methods
remove()
click to toggle source
# File lib/bitbroker/metadata.rb, line 109 def remove @status |= STATUS_REMOVED end
removed?()
click to toggle source
# File lib/bitbroker/metadata.rb, line 106 def removed? @status & STATUS_REMOVED > 0 end
to_h()
click to toggle source
# File lib/bitbroker/metadata.rb, line 112 def to_h { 'path' => @path, 'status' => @status, 'size' => @size, 'mtime' => @mtime.to_s, } end
update()
click to toggle source
# File lib/bitbroker/metadata.rb, line 95 def update if FileTest.exist? @fpath file = File.new(@fpath) @size = file.size @mtime = file.mtime else @size = 0 @mtime = Time.new(0) end end