Class: Rucola::FSEvents::FSEvent
Instance Attribute Summary collapse
-
#fsevents_object ⇒ Object
readonly
Returns the value of attribute fsevents_object.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#files ⇒ Object
Returns an array of the files/dirs in the path that the event occurred in.
-
#initialize(fsevents_object, id, path) ⇒ FSEvent
constructor
A new instance of FSEvent.
-
#last_modified_file ⇒ Object
Returns the last modified file in the path that the event occurred in.
Constructor Details
#initialize(fsevents_object, id, path) ⇒ FSEvent
Returns a new instance of FSEvent.
9 10 11 |
# File 'lib/rucola/fsevents.rb', line 9 def initialize(fsevents_object, id, path) @fsevents_object, @id, @path = fsevents_object, id, path end |
Instance Attribute Details
#fsevents_object ⇒ Object (readonly)
Returns the value of attribute fsevents_object.
6 7 8 |
# File 'lib/rucola/fsevents.rb', line 6 def fsevents_object @fsevents_object end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/rucola/fsevents.rb', line 7 def id @id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/rucola/fsevents.rb', line 8 def path @path end |
Instance Method Details
#files ⇒ Object
Returns an array of the files/dirs in the path that the event occurred in. The files are sorted by the modification time, the first entry is the last modified file.
15 16 17 |
# File 'lib/rucola/fsevents.rb', line 15 def files Dir.glob("#{File.(path)}/*").sort_by {|f| File.mtime(f) }.reverse end |
#last_modified_file ⇒ Object
Returns the last modified file in the path that the event occurred in.
20 21 22 |
# File 'lib/rucola/fsevents.rb', line 20 def last_modified_file files.first end |