Class: CZTop::Config::Traversing::FamilyAccessor Abstract

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

Overview

This class is abstract.

Used to give access to a CZTop::Config item's children or siblings.

Direct Known Subclasses

ChildrenAccessor, SiblingsAccessor

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FamilyAccessor

Returns a new instance of FamilyAccessor.

Parameters:

  • config (Config)

    the relative starting point (either parent or an older sibling)


66
67
68
# File 'lib/cztop/config/traversing.rb', line 66

def initialize(config)
  @config = config
end

Instance Method Details

#==(other) ⇒ Object

Recursively compares these config items with the ones of the other.

Parameters:


91
92
93
94
95
96
97
98
# File 'lib/cztop/config/traversing.rb', line 91

def ==(other)
  these = to_a
  those = other.to_a
  these.size == those.size && these.zip(those) do |this, that|
    this.tree_equal?(that) or return false
  end
  return true
end

#each {|config| ... } ⇒ Object

Yields all direct children/younger siblings. Starts with #first, if set.

Yield Parameters:


78
79
80
81
82
83
84
85
86
87
# File 'lib/cztop/config/traversing.rb', line 78

def each
  current = first()
  return if current.nil?
  yield current
  current_delegate = current.ffi_delegate
  while current_delegate = current_delegate.next
    break if current_delegate.null?
    yield CZTop::Config.from_ffi_delegate(current_delegate)
  end
end

#firstConfig?

This method is abstract.

This is supposed to return the first relevant config item.

Returns:


73
# File 'lib/cztop/config/traversing.rb', line 73

def first; end