Class: Lich::Common::SetupFiles::FileInfo

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(path:, name:, data:, mtime:) ⇒ FileInfo

Initializes a FileInfo cache entry.

Parameters:

  • path (String)

    directory path containing the file

  • name (String)

    filename (basename)

  • data (Hash)

    parsed YAML data

  • mtime (Time)

    file modification time



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

#mtimeObject (readonly)

Returns the value of attribute mtime.



58
59
60
# File 'documented/common/setup_files.rb', line 58

def mtime
  @mtime
end

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'documented/common/setup_files.rb', line 58

def name
  @name
end

#pathObject (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

#dataObject

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

#inspectString

Returns a string representation of the cached file metadata.

Returns:

  • (String)

    formatted inspection output



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_sString

Returns the full filepath as a string.

Returns:

  • (String)

    joined path and filename



87
88
89
# File 'documented/common/setup_files.rb', line 87

def to_s
  File.join(@path, @name)
end