Class: Autorespawn::TrackedFile
- Inherits:
-
Object
- Object
- Autorespawn::TrackedFile
- Defined in:
- lib/autorespawn/tracked_file.rb
Instance Attribute Summary collapse
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#slaves ⇒ Object
readonly
Returns the value of attribute slaves.
Instance Method Summary collapse
-
#initialize(path, mtime: nil, size: nil) ⇒ TrackedFile
constructor
A new instance of TrackedFile.
- #update ⇒ Object
Constructor Details
#initialize(path, mtime: nil, size: nil) ⇒ TrackedFile
Returns a new instance of TrackedFile.
5 6 7 8 9 10 |
# File 'lib/autorespawn/tracked_file.rb', line 5 def initialize(path, mtime: nil, size: nil) @path = path @mtime = mtime @size = size @slaves = Array.new end |
Instance Attribute Details
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
3 4 5 |
# File 'lib/autorespawn/tracked_file.rb', line 3 def mtime @mtime end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/autorespawn/tracked_file.rb', line 3 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/autorespawn/tracked_file.rb', line 3 def size @size end |
#slaves ⇒ Object (readonly)
Returns the value of attribute slaves.
3 4 5 |
# File 'lib/autorespawn/tracked_file.rb', line 3 def slaves @slaves end |
Instance Method Details
#update ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/autorespawn/tracked_file.rb', line 12 def update return true if !path.exist? return true if !mtime stat = path.stat if stat.mtime != mtime || stat.size != size @mtime = stat.mtime @size = stat.size true end end |