Class: Pack::Entry
Instance Attribute Summary collapse
-
#delta ⇒ Object
readonly
Returns the value of attribute delta.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#oid ⇒ Object
readonly
Returns the value of attribute oid.
Instance Method Summary collapse
- #assign_delta(delta) ⇒ Object
- #delta_prefix ⇒ Object
-
#initialize(oid, info, path, ofs = false) ⇒ Entry
constructor
A new instance of Entry.
- #packed_size ⇒ Object
- #packed_type ⇒ Object
- #sort_key ⇒ Object
Constructor Details
#initialize(oid, info, path, ofs = false) ⇒ Entry
Returns a new instance of Entry.
13 14 15 16 17 18 19 20 |
# File 'lib/pack/entry.rb', line 13 def initialize(oid, info, path, ofs = false) @oid = oid @info = info @path = path @ofs = ofs @delta = nil @depth = 0 end |
Instance Attribute Details
#delta ⇒ Object (readonly)
Returns the value of attribute delta.
11 12 13 |
# File 'lib/pack/entry.rb', line 11 def delta @delta end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
11 12 13 |
# File 'lib/pack/entry.rb', line 11 def depth @depth end |
#offset ⇒ Object
Returns the value of attribute offset.
10 11 12 |
# File 'lib/pack/entry.rb', line 10 def offset @offset end |
#oid ⇒ Object (readonly)
Returns the value of attribute oid.
11 12 13 |
# File 'lib/pack/entry.rb', line 11 def oid @oid end |
Instance Method Details
#assign_delta(delta) ⇒ Object
26 27 28 29 |
# File 'lib/pack/entry.rb', line 26 def assign_delta(delta) @delta = delta @depth = delta.base.depth + 1 end |
#delta_prefix ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/pack/entry.rb', line 43 def delta_prefix return "" unless @delta if @ofs Numbers::VarIntBE.write(offset - @delta.base.offset) else [@delta.base.oid].pack("H40") end end |
#packed_size ⇒ Object
39 40 41 |
# File 'lib/pack/entry.rb', line 39 def packed_size @delta ? @delta.size : @info.size end |
#packed_type ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/pack/entry.rb', line 31 def packed_type if @delta @ofs ? OFS_DELTA : REF_DELTA else TYPE_CODES.fetch(@info.type) end end |
#sort_key ⇒ Object
22 23 24 |
# File 'lib/pack/entry.rb', line 22 def sort_key [packed_type, @path&.basename, @path&.dirname, @info.size] end |