Class: CZTop::Config::Traversing::ChildrenAccessor

Inherits:
FamilyAccessor show all
Defined in:
lib/cztop/config/traversing.rb

Overview

Accesses the direct children of a given CZTop::Config item.

Instance Method Summary collapse

Methods inherited from FamilyAccessor

#==, #each, #initialize

Constructor Details

This class inherits a constructor from CZTop::Config::Traversing::FamilyAccessor

Instance Method Details

#firstObject


115
116
117
118
119
# File 'lib/cztop/config/traversing.rb', line 115

def first
  ptr = @config.ffi_delegate.child
  return nil if ptr.null?
  CZTop::Config.from_ffi_delegate(ptr)
end

#new(name = nil, value = nil) {|config| ... } ⇒ Config

Adds a new Config item and yields it, so it can be configured in a block.

Parameters:

  • name (String) (defaults to: nil)

    name for new config item

  • value (String) (defaults to: nil)

    value for new config item

Yield Parameters:

  • config (Config)

    the new config item, if block was given

Returns:

  • (Config)

    the new config item


127
128
129
130
131
# File 'lib/cztop/config/traversing.rb', line 127

def new(name = nil, value = nil)
  config = CZTop::Config.new(name, value, parent: @config)
  yield config if block_given?
  config
end