Class: GitCache::RefInfo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/git_cache/repo_info.rb

Overview

Information about a git ref used in a cache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_accessedTime? (readonly)

The timestamp when this ref was last accessed

Returns:

  • (Time, nil)


137
138
139
# File 'lib/git_cache/repo_info.rb', line 137

def last_accessed
  @last_accessed
end

#last_updatedTime? (readonly)

The timestamp when this ref was last updated

Returns:

  • (Time, nil)


144
145
146
# File 'lib/git_cache/repo_info.rb', line 144

def last_updated
  @last_updated
end

#refString (readonly)

The git ref

Returns:

  • (String)


123
124
125
# File 'lib/git_cache/repo_info.rb', line 123

def ref
  @ref
end

#shaString (readonly)

The git sha last associated with the ref

Returns:

  • (String)


130
131
132
# File 'lib/git_cache/repo_info.rb', line 130

def sha
  @sha
end

Instance Method Details

#<=>(other) ⇒ Integer

Comparison function

Parameters:

Returns:

  • (Integer)


167
168
169
# File 'lib/git_cache/repo_info.rb', line 167

def <=>(other)
  ref <=> other.ref
end

#to_hHash

Convert this RefInfo to a hash suitable for JSON output

Returns:

  • (Hash)


151
152
153
154
155
156
157
158
159
# File 'lib/git_cache/repo_info.rb', line 151

def to_h
  result = {
    "ref" => ref,
    "sha" => sha,
  }
  result["last_accessed"] = last_accessed.to_i if last_accessed
  result["last_updated"] = last_updated.to_i if last_updated
  result
end