Class: Rados::Object
- Inherits:
-
Object
- Object
- Rados::Object
- Defined in:
- lib/rados.rb
Overview
A Rados::Object represents an object in a pool in a cluster.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Object
constructor
A new instance of Object.
- #read ⇒ Object
- #seek(amount, whence = IO::SEEK_SET) ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Object
Returns a new instance of Object.
43 44 45 46 47 |
# File 'lib/rados.rb', line 43 def initialize(attributes = {}) @id = attributes[:id] @pool = attributes[:pool] @position = 0 end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
41 42 43 |
# File 'lib/rados.rb', line 41 def id @id end |
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
41 42 43 |
# File 'lib/rados.rb', line 41 def pool @pool end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
41 42 43 |
# File 'lib/rados.rb', line 41 def position @position end |
Instance Method Details
#read ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rados.rb', line 56 def read # FIXME: If the following does a part read and raises an # exception then the @position is invalid buf = pool.read(id, :offset => @position) if buf.size == 0 nil else @position += buf.size buf end end |
#seek(amount, whence = IO::SEEK_SET) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/rados.rb', line 68 def seek(amount, whence = IO::SEEK_SET) case whence when IO::SEEK_SET @position = amount when IO::SEEK_CUR @position += amount end end |
#write(buf) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/rados.rb', line 49 def write(buf) # FIXME: If the following does a part write and raises an # exception then the @position is invalid @position += pool.write(id, buf, :offset => @position) self end |