class Kitchen::TypeCastingElementEnumerator
An enumerator that detects the element type as it iterates and returns specific, different element classes based on that type.
Public Class Methods
factory()
click to toggle source
Returns a factory for this enumerator
@return [ElementEnumeratorFactory]
# File lib/kitchen/type_casting_element_enumerator.rb, line 13 def self.factory ElementEnumeratorFactory.new( enumerator_class: self, detect_sub_element_class: true ) end
Public Instance Methods
only(*element_classes)
click to toggle source
Returns a new enumerator that returns only the specified element classes within the scope of this enumerator.
@param element_classes [Array<ElementBase>] the element classes to limit iteration to @return [TypeCastingElementEnumerator]
# File lib/kitchen/type_casting_element_enumerator.rb, line 26 def only(*element_classes) element_classes.flatten! TypeCastingElementEnumerator.new do |block| each do |element| next unless element_classes.include?(element.class) block.yield(element) end end end