Class: BitBroker::ManagerImpl::FileActivity

Inherits:
Object
  • Object
show all
Defined in:
lib/bitbroker/manager_impl.rb

Constant Summary collapse

STATUS_REMOVED =
1 << 0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, mtime, status = 0) ⇒ FileActivity

Returns a new instance of FileActivity.



259
260
261
262
263
# File 'lib/bitbroker/manager_impl.rb', line 259

def initialize(path, mtime, status = 0)
  @path = path
  @mtime = mtime
  @status = status
end

Instance Attribute Details

#mtimeObject (readonly)

Returns the value of attribute mtime.



257
258
259
# File 'lib/bitbroker/manager_impl.rb', line 257

def mtime
  @mtime
end

#pathObject (readonly)

Returns the value of attribute path.



257
258
259
# File 'lib/bitbroker/manager_impl.rb', line 257

def path
  @path
end

Class Method Details

.create(path) ⇒ Object



269
270
271
# File 'lib/bitbroker/manager_impl.rb', line 269

def self.create(path)
  self.new(path, FileTest.exist?(path) ? File.mtime(path) : Time.now)
end

.remove(path) ⇒ Object



273
274
275
# File 'lib/bitbroker/manager_impl.rb', line 273

def self.remove(path)
  self.new(path, nil, STATUS_REMOVED)
end

Instance Method Details

#removed?Boolean

Returns:

  • (Boolean)


265
266
267
# File 'lib/bitbroker/manager_impl.rb', line 265

def removed?
  @status & STATUS_REMOVED > 0
end