Class: Enumerable::ByDepthDelegator

Inherits:
TreeDelegator show all
Defined in:
lib/agents/sets/enum/tree.rb

Instance Attribute Summary

Attributes inherited from TreeDelegator

#args, #child_map, #child_name, #output_type, #root

Instance Method Summary collapse

Methods inherited from TreeDelegator

#get_children, #initialize

Methods included from Enumerable

#each_cluster, #each_with_neighbors, #group, nest, #nest, #pipe

Constructor Details

This class inherits a constructor from Enumerable::TreeDelegator

Instance Method Details

#branchesObject



73
74
75
76
# File 'lib/agents/sets/enum/tree.rb', line 73

def branches
  @output_type = :branches
  self
end

#each(*args, &block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/agents/sets/enum/tree.rb', line 78

def each(*args, &block)
  case @output_type
  when :nodes
    each_node *args, &block
  when :with_ancestors
    each_with_ancestors *args, &block
  when :branches
    each_branch *args, &block
  end
end

#with_ancestorsObject



68
69
70
71
# File 'lib/agents/sets/enum/tree.rb', line 68

def with_ancestors
  @output_type = :with_ancestors
  self
end