Class: Listen::Record::Entry
- Inherits:
-
Object
- Object
- Listen::Record::Entry
- Defined in:
- lib/listen/record/entry.rb
Overview
Represents a directory entry (dir or file)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relative ⇒ Object
readonly
Returns the value of attribute relative.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(root, relative, name = nil) ⇒ Entry
constructor
file: “/home/me/watched_dir”, “app/models”, “foo.rb” dir, “/home/me/watched_dir”, “.”.
- #meta ⇒ Object
- #real_path ⇒ Object
-
#record_dir_key ⇒ Object
record hash is e.g.
- #sys_path ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/listen/record/entry.rb', line 16 def name @name end |
#relative ⇒ Object (readonly)
Returns the value of attribute relative.
16 17 18 |
# File 'lib/listen/record/entry.rb', line 16 def relative @relative end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
16 17 18 |
# File 'lib/listen/record/entry.rb', line 16 def root @root end |
Instance Method Details
#children ⇒ Object
18 19 20 21 22 23 |
# File 'lib/listen/record/entry.rb', line 18 def children child_relative = _join (_entries(sys_path) - %w[. ..]).map do |name| Entry.new(@root, child_relative, name) end end |
#meta ⇒ Object
25 26 27 28 |
# File 'lib/listen/record/entry.rb', line 25 def lstat = ::File.lstat(sys_path) { mtime: lstat.mtime.to_f, mode: lstat.mode, size: lstat.size } end |
#real_path ⇒ Object
43 44 45 |
# File 'lib/listen/record/entry.rb', line 43 def real_path @real_path ||= ::File.realpath(sys_path) end |
#record_dir_key ⇒ Object
record hash is e.g. if @record[“project/app/models”] if @record[“project/app”] record_dir_key is “project/app/models”
34 35 36 |
# File 'lib/listen/record/entry.rb', line 34 def record_dir_key ::File.join(*[@relative, @name].compact) end |
#sys_path ⇒ Object
38 39 40 41 |
# File 'lib/listen/record/entry.rb', line 38 def sys_path # Use full path in case someone uses chdir ::File.join(*[@root, @relative, @name].compact) end |