Class: Lich::Common::SetupFiles::FileInfo
- Inherits:
-
Object
- Object
- Lich::Common::SetupFiles::FileInfo
- Defined in:
- documented/common/setup_files.rb
Overview
Cached metadata and content for a single YAML configuration file.
Stores the file path, name, modification time, and parsed YAML data. Provides deep-clone access to prevent scripts from mutating cached data.
Instance Attribute Summary collapse
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#data ⇒ Object
Deep clone of data to prevent scripts from mutating cached settings.
-
#initialize(path:, name:, data:, mtime:) ⇒ FileInfo
constructor
Initializes a FileInfo cache entry.
-
#inspect ⇒ String
Returns a string representation of the cached file metadata.
-
#peek(property) ⇒ Object
Efficient deep clone of a single property.
-
#to_s ⇒ String
Returns the full filepath as a string.
Constructor Details
#initialize(path:, name:, data:, mtime:) ⇒ FileInfo
Initializes a FileInfo cache entry.
67 68 69 70 71 72 |
# File 'documented/common/setup_files.rb', line 67 def initialize(path:, name:, data:, mtime:) @path = path @name = name @data = data @mtime = mtime end |
Instance Attribute Details
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
58 59 60 |
# File 'documented/common/setup_files.rb', line 58 def mtime @mtime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
58 59 60 |
# File 'documented/common/setup_files.rb', line 58 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
58 59 60 |
# File 'documented/common/setup_files.rb', line 58 def path @path end |
Instance Method Details
#data ⇒ Object
Deep clone of data to prevent scripts from mutating cached settings.
75 76 77 |
# File 'documented/common/setup_files.rb', line 75 def data Marshal.load(Marshal.dump(@data)) end |
#inspect ⇒ String
Returns a string representation of the cached file metadata.
94 95 96 |
# File 'documented/common/setup_files.rb', line 94 def inspect "#<SetupFiles::FileInfo @name=#{@name}, @path=#{@path}, @mtime=#{@mtime}>" end |
#peek(property) ⇒ Object
Efficient deep clone of a single property.
80 81 82 |
# File 'documented/common/setup_files.rb', line 80 def peek(property) Marshal.load(Marshal.dump(@data[property.to_sym])) end |
#to_s ⇒ String
Returns the full filepath as a string.
87 88 89 |
# File 'documented/common/setup_files.rb', line 87 def to_s File.join(@path, @name) end |