Class: BFS::Blob
- Inherits:
-
Object
- Object
- BFS::Blob
- Defined in:
- lib/bfs/blob.rb
Overview
Blobs are references to single blob objects within a bucket.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the underlying bucket connection.
-
#create(**opts, &block) ⇒ Object
Creates the blob and opens it for writing.
-
#info(**opts) ⇒ Object
Info returns the blob info.
-
#initialize(url) ⇒ Blob
constructor
A new instance of Blob.
-
#mv(dst, **opts) ⇒ Object
Moves blob to dst.
-
#open(**opts, &block) ⇒ Object
Opens the blob for reading.
-
#read(**opts) ⇒ Object
Shortcut method to read the contents of the blob.
-
#rm(**opts) ⇒ Object
Deletes the blob.
-
#write(data, **opts) ⇒ Object
Shortcut method to write data to blob.
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/bfs/blob.rb', line 4 def path @path end |
Instance Method Details
#close ⇒ Object
Closes the underlying bucket connection.
53 54 55 |
# File 'lib/bfs/blob.rb', line 53 def close @bucket.close end |
#create(**opts, &block) ⇒ Object
Creates the blob and opens it for writing.
20 21 22 |
# File 'lib/bfs/blob.rb', line 20 def create(**opts, &block) @bucket.create(path, **opts, &block) end |
#info(**opts) ⇒ Object
Info returns the blob info.
15 16 17 |
# File 'lib/bfs/blob.rb', line 15 def info(**opts) @bucket.info(path, **opts) end |
#mv(dst, **opts) ⇒ Object
Moves blob to dst.
46 47 48 49 50 |
# File 'lib/bfs/blob.rb', line 46 def mv(dst, **opts) dst = BFS.norm_path(dst) @bucket.mv(path, dst, **opts) @path = dst end |
#open(**opts, &block) ⇒ Object
Opens the blob for reading. May raise BFS::FileNotFound.
26 27 28 |
# File 'lib/bfs/blob.rb', line 26 def open(**opts, &block) @bucket.open(path, **opts, &block) end |
#read(**opts) ⇒ Object
Shortcut method to read the contents of the blob.
36 37 38 |
# File 'lib/bfs/blob.rb', line 36 def read(**opts) open(**opts, &:read) end |
#rm(**opts) ⇒ Object
Deletes the blob.
31 32 33 |
# File 'lib/bfs/blob.rb', line 31 def rm(**opts) @bucket.rm(path, **opts) end |
#write(data, **opts) ⇒ Object
Shortcut method to write data to blob.
41 42 43 |
# File 'lib/bfs/blob.rb', line 41 def write(data, **opts) create(**opts) {|f| f.write data } end |