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



135
136
137
138
139
140
# File 'lib/cztop/config/traversing.rb', line 135

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



149
150
151
152
153
# File 'lib/cztop/config/traversing.rb', line 149

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