Class: DurableHuggingfaceHub::Types::CachedRevisionInfo

Inherits:
Struct
  • Object
show all
Includes:
Loadable
Defined in:
lib/durable_huggingface_hub/types/cache_info.rb

Overview

Information about a cached repository revision.

Represents a specific revision (commit, branch, or tag) of a repository in the cache.

Examples:

revision = CachedRevisionInfo.new(
  commit_hash: "abc123",
  refs: ["main", "v1.0"],
  files: [cached_file_info1, cached_file_info2],
  size: 2048,
  last_modified: Time.now
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commit_hashString (readonly)

Git commit hash for this revision

Returns:

  • (String)


88
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 88

attribute :commit_hash, Types::String

#filesArray<CachedFileInfo> (readonly)

List of cached files in this revision

Returns:



98
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 98

attribute :files, Types::Array.of(CachedFileInfo)

#last_modifiedTime? (readonly)

When this revision was last modified

Returns:

  • (Time, nil)


108
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 108

attribute :last_modified, Types::OptionalTimestamp.default(nil)

#refsArray<String> (readonly)

List of refs (branches/tags) pointing to this commit

Returns:

  • (Array<String>)


93
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 93

attribute :refs, Types::StringArray

#sizeInteger (readonly)

Total size of all files in this revision

Returns:

  • (Integer)


103
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 103

attribute :size, Types::Integer

Instance Method Details

#file_countInteger

Number of files in this revision.

Returns:

  • (Integer)

    File count



129
130
131
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 129

def file_count
  files.length
end

#size_strString

Human-readable size string.

Returns:

  • (String)

    Size formatted as human-readable string



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/durable_huggingface_hub/types/cache_info.rb', line 113

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