Class: DurableHuggingfaceHub::Types::CachedFileInfo
- Includes:
- Loadable
- Defined in:
- lib/durable_huggingface_hub/types/cache_info.rb
Overview
Information about a cached file.
Represents a single file in the cache with its metadata.
Instance Attribute Summary collapse
-
#commit_hash ⇒ String?
readonly
Git commit hash this file belongs to.
-
#etag ⇒ String?
readonly
ETag of the file (used for cache validation).
-
#file_path ⇒ Pathname
readonly
Path to the cached file.
-
#last_accessed ⇒ Time?
readonly
When the file was last accessed.
-
#last_modified ⇒ Time?
readonly
When the file was last modified.
-
#size ⇒ Integer
readonly
Size of the file in bytes.
Instance Method Summary collapse
-
#size_str ⇒ String
Human-readable size string.
Instance Attribute Details
#commit_hash ⇒ String? (readonly)
Git commit hash this file belongs to
41 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 41 attribute :commit_hash, Types::OptionalString.default(nil) |
#etag ⇒ String? (readonly)
ETag of the file (used for cache validation)
36 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 36 attribute :etag, Types::OptionalString |
#file_path ⇒ Pathname (readonly)
Path to the cached file
26 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 26 attribute :file_path, Types::PathnameType |
#last_accessed ⇒ Time? (readonly)
When the file was last accessed
46 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 46 attribute :last_accessed, Types::OptionalTimestamp.default(nil) |
#last_modified ⇒ Time? (readonly)
When the file was last modified
51 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 51 attribute :last_modified, Types::OptionalTimestamp.default(nil) |
#size ⇒ Integer (readonly)
Size of the file in bytes
31 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 31 attribute :size, Types::Integer |
Instance Method Details
#size_str ⇒ String
Human-readable size string.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 56 def size_str units = ["B", "KB", "MB", "GB", "TB"] size = self.size.to_f unit_index = 0 while size >= 1024 && unit_index < units.length - 1 size /= 1024.0 unit_index += 1 end format("%.2f %s", size, units[unit_index]) end |