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)



74
75
76
# File 'lib/cztop/config/traversing.rb', line 74

def initialize(config)
  @config = config
end

Instance Method Details

#==(other) ⇒ Object

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

Parameters:



104
105
106
107
108
109
110
111
# File 'lib/cztop/config/traversing.rb', line 104

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
  true
end

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

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

Yield Parameters:



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

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:



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

def first; end