Class: GitObjectBrowser::Models::IndexTreeExtension
- Defined in:
- lib/git-object-browser/models/index_tree_extension.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#total_length ⇒ Object
readonly
Returns the value of attribute total_length.
Instance Method Summary collapse
-
#initialize(input) ⇒ IndexTreeExtension
constructor
A new instance of IndexTreeExtension.
- #parse ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Bindata
#binstr, #byte, #bytes, #find_char, #hex, #int, #peek, #raw, #seek, #skip, #switch_source
Constructor Details
#initialize(input) ⇒ IndexTreeExtension
Returns a new instance of IndexTreeExtension.
9 10 11 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 9 def initialize(input) super(input) end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
7 8 9 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 7 def entries @entries end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
7 8 9 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 7 def signature @signature end |
#total_length ⇒ Object (readonly)
Returns the value of attribute total_length.
7 8 9 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 7 def total_length @total_length end |
Instance Method Details
#parse ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 13 def parse @signature = raw(4) # TREE @total_length = int @entries = [] length = 0 while (length < @total_length) entry = {} entry[:path_component] = find_char "\0" entry[:entry_count] = find_char " " entry[:subtree_count] = find_char "\n" length += entry[:path_component].bytesize + 1 length += entry[:entry_count].bytesize + 1 length += entry[:subtree_count].bytesize + 1 entry[:entry_count] = entry[:entry_count].to_i entry[:subtree_count] = entry[:subtree_count].to_i if 0 <= entry[:entry_count] entry[:sha1] = hex(20) length += 20 end @entries << entry end self end |
#to_hash ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/git-object-browser/models/index_tree_extension.rb', line 42 def to_hash return { :signature => @signature, :total_length => @total_length, :entries => @entries } end |