class CZTop::Config::CommentsAccessor

Used to access a {Config}'s comments.

Public Class Methods

new(config) click to toggle source

@param config [Config]

# File lib/cztop/config/comments.rb, line 18
def initialize(config)
  @config = config
end

Public Instance Methods

<<(new_comment) click to toggle source

Adds a new comment. @param new_comment [String] @return [self]

# File lib/cztop/config/comments.rb, line 25
def <<(new_comment)
  @config.ffi_delegate.set_comment("%s", :string, new_comment)
  return self
end
delete_all() click to toggle source

Deletes all comments for this {Config} item. @return [void]

# File lib/cztop/config/comments.rb, line 32
def delete_all
  @config.ffi_delegate.set_comment(nil)
end
each() { |read_string| ... } click to toggle source

Yields all comments for this {Config} item. @yieldparam comment [String] @return [void]

# File lib/cztop/config/comments.rb, line 39
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() click to toggle source

Returns the number of comments for this {Config} item. @return [Integer] number of comments

# File lib/cztop/config/comments.rb, line 51
def size
  _zlist.size
rescue CZMQ::FFI::Zlist::DestroyedError
  0
end

Private Instance Methods

_zlist() click to toggle source

Returns the Zlist to the list of comments for this config item. @return [CZMQ::FFI::Zlist] the zlist of comments for this config item

# File lib/cztop/config/comments.rb, line 61
def _zlist
  @config.ffi_delegate.comments
end