Class: CZTop::Config::CommentsAccessor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/cztop/config/comments.rb

Overview

Used to access a CZTop::Config‘s comments.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ CommentsAccessor

Returns a new instance of CommentsAccessor.

Parameters:



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.

Parameters:

  • new_comment (String)

Returns:

  • (self)


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_allvoid

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.

Yield Parameters:

  • comment (String)


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

#sizeInteger

Returns the number of comments for this CZTop::Config item.

Returns:

  • (Integer)

    number of comments



60
61
62
63
64
# File 'lib/cztop/config/comments.rb', line 60

def size
  _zlist.size
rescue CZMQ::FFI::Zlist::DestroyedError
  0
end