Class: GitDump::Entry
- Inherits:
-
PathObject
- Object
- PathObject
- GitDump::Entry
- Defined in:
- lib/git_dump/entry.rb
Overview
Entry at path
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Attributes inherited from PathObject
Instance Method Summary collapse
-
#initialize(repo, dir, name, sha, mode) ⇒ Entry
constructor
A new instance of Entry.
- #inspect ⇒ Object
-
#open(&block) ⇒ Object
Pipe for reading data.
-
#read ⇒ Object
Data.
-
#size ⇒ Object
Get size.
-
#write_to(path) ⇒ Object
Write to path.
Constructor Details
#initialize(repo, dir, name, sha, mode) ⇒ Entry
Returns a new instance of Entry.
9 10 11 12 |
# File 'lib/git_dump/entry.rb', line 9 def initialize(repo, dir, name, sha, mode) super(repo, dir, name) @sha, @mode = sha, (mode & 0o100) == 0 ? 0o644 : 0o755 end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
8 9 10 |
# File 'lib/git_dump/entry.rb', line 8 def mode @mode end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
8 9 10 |
# File 'lib/git_dump/entry.rb', line 8 def sha @sha end |
Instance Method Details
#inspect ⇒ Object
34 35 36 |
# File 'lib/git_dump/entry.rb', line 34 def inspect "#<#{self.class} sha=#{@sha} mode=#{format '%03o', @mode}>" end |
#open(&block) ⇒ Object
Pipe for reading data
20 21 22 |
# File 'lib/git_dump/entry.rb', line 20 def open(&block) repo.blob_pipe(sha, &block) end |
#read ⇒ Object
Data
25 26 27 |
# File 'lib/git_dump/entry.rb', line 25 def read repo.blob_read(sha) end |
#size ⇒ Object
Get size
15 16 17 |
# File 'lib/git_dump/entry.rb', line 15 def size @size ||= repo.size(sha) end |
#write_to(path) ⇒ Object
Write to path
30 31 32 |
# File 'lib/git_dump/entry.rb', line 30 def write_to(path) repo.blob_unpack(sha, path, mode) end |