Class: Watchcat::Event
- Inherits:
-
Object
- Object
- Watchcat::Event
- Defined in:
- lib/watchcat/event.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#raw_kind ⇒ Object
readonly
Returns the value of attribute raw_kind.
Instance Method Summary collapse
- #deconstruct_keys(_keys) ⇒ Object
- #dest_path ⇒ Object
- #directory? ⇒ Boolean
-
#initialize(kinds, paths, raw_kind) ⇒ Event
constructor
A new instance of Event.
- #src_path ⇒ Object
Constructor Details
#initialize(kinds, paths, raw_kind) ⇒ Event
Returns a new instance of Event.
7 8 9 10 11 |
# File 'lib/watchcat/event.rb', line 7 def initialize(kinds, paths, raw_kind) @paths = paths @raw_kind = raw_kind build_kind(kinds) end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/watchcat/event.rb', line 5 def event @event end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/watchcat/event.rb', line 5 def kind @kind end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
5 6 7 |
# File 'lib/watchcat/event.rb', line 5 def paths @paths end |
#raw_kind ⇒ Object (readonly)
Returns the value of attribute raw_kind.
5 6 7 |
# File 'lib/watchcat/event.rb', line 5 def raw_kind @raw_kind end |
Instance Method Details
#deconstruct_keys(_keys) ⇒ Object
13 14 15 |
# File 'lib/watchcat/event.rb', line 13 def deconstruct_keys(_keys) { paths: @paths, event: @event } end |
#dest_path ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/watchcat/event.rb', line 40 def dest_path return nil unless rename_event? rename = kind.modify.rename return @paths[1] if rename.both? return @paths[0] if rename.to? nil end |
#directory? ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/watchcat/event.rb', line 17 def directory? if kind.create? kind.create.folder? elsif kind.remove? kind.remove.folder? elsif kind.any? kind.any.folder? else File.directory?(@paths.first) end rescue false end |
#src_path ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/watchcat/event.rb', line 31 def src_path return nil unless rename_event? rename = kind.modify.rename return @paths[0] if rename.both? || rename.from? nil end |