Class: MultiGit::Blob::Builder
- Inherits:
-
StringIO
- Object
- StringIO
- MultiGit::Blob::Builder
- Includes:
- Base, MultiGit::Builder
- Defined in:
- lib/multi_git/blob.rb
Instance Method Summary collapse
- #>>(repo) ⇒ Object
- #content=(value) ⇒ Object
-
#initialize(content = nil) ⇒ Builder
constructor
A new instance of Builder.
- #oid ⇒ Object
-
#with_parent(parent, name) ⇒ File::Builder
Turns the blob into a file using the given parent and filename.
Methods included from MultiGit::Builder
Methods included from Utils::AbstractMethods
Methods included from Base
Constructor Details
#initialize(content = nil) ⇒ Builder
Returns a new instance of Builder.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/multi_git/blob.rb', line 32 def initialize(content = nil) super() if content.kind_of? Blob self << content.content elsif content.kind_of? String self << content elsif content.kind_of? IO IO.copy_stream(content, self) elsif content raise ArgumentError end end |
Instance Method Details
#>>(repo) ⇒ Object
51 52 53 54 |
# File 'lib/multi_git/blob.rb', line 51 def >>(repo) rewind return repo.write(read) end |
#content=(value) ⇒ Object
47 48 49 |
# File 'lib/multi_git/blob.rb', line 47 def content=(value) self.string = value.dup end |
#oid ⇒ Object
56 57 58 59 60 61 |
# File 'lib/multi_git/blob.rb', line 56 def oid dig = Digest::SHA1.new dig << "blob #{size}\0" dig << content return dig.hexdigest end |
#with_parent(parent, name) ⇒ File::Builder
Turns the blob into a file using the given parent and filename.
67 68 69 |
# File 'lib/multi_git/blob.rb', line 67 def with_parent(parent, name) File::Builder.new(parent, name, self) end |