Class: CZTop::Config::CommentsAccessor
- Inherits:
-
Object
- Object
- CZTop::Config::CommentsAccessor
- Includes:
- Enumerable
- Defined in:
- lib/cztop/config/comments.rb
Overview
Used to access a CZTop::Config‘s comments.
Instance Method Summary collapse
-
#<<(new_comment) ⇒ self
Adds a new comment.
-
#delete_all ⇒ void
Deletes all comments for this CZTop::Config item.
-
#each {|comment| ... } ⇒ void
Yields all comments for this CZTop::Config item.
-
#initialize(config) ⇒ CommentsAccessor
constructor
A new instance of CommentsAccessor.
-
#size ⇒ Integer
Returns the number of comments for this CZTop::Config item.
Constructor Details
#initialize(config) ⇒ CommentsAccessor
Returns a new instance of CommentsAccessor.
22 23 24 |
# File 'lib/cztop/config/comments.rb', line 22 def initialize(config) @config = config end |
Instance Method Details
#<<(new_comment) ⇒ self
Adds a new comment.
30 31 32 33 |
# File 'lib/cztop/config/comments.rb', line 30 def <<(new_comment) @config.ffi_delegate.set_comment('%s', :string, new_comment) self end |
#delete_all ⇒ void
This method returns an undefined value.
Deletes all comments for this CZTop::Config item.
38 39 40 |
# File 'lib/cztop/config/comments.rb', line 38 def delete_all @config.ffi_delegate.set_comment(nil) end |
#each {|comment| ... } ⇒ void
This method returns an undefined value.
Yields all comments for this CZTop::Config item.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cztop/config/comments.rb', line 46 def each while comment = _zlist.next break if comment.null? yield comment.read_string end rescue CZMQ::FFI::Zlist::DestroyedError # there are no comments nil end |
#size ⇒ Integer
Returns the number of comments for this CZTop::Config item.
60 61 62 63 64 |
# File 'lib/cztop/config/comments.rb', line 60 def size _zlist.size rescue CZMQ::FFI::Zlist::DestroyedError 0 end |