lib/cli/mastermind.rb
# Removes plans whose names don't match the given pattern from the tree.
#
# Modifies +plans+ in place!
#
# @param pattern [Regexp] the pattern to match against
# @param plans [ParentPlan, Hash<name, Plan>] the plans to filter
#
# @return [Void]
Removes plans whose names don't match the given pattern from the tree.
Modifies +plans+ in place!
Removes plans whose names don ' t match the given pattern from the tree . Modifies + plans + in place!
def filter_plans(pattern, plans=self.plans)
        plans.keep_if do |name, plan|
          next false unless plan.has_children? or plan.description
          next true if name =~ pattern
          next false unless plan.has_children?
          filter_plans(pattern, plan.children)
          plan.has_children?
        end
      end
def filter_plans ( pattern , plans = self . plans ) plans . keep_if do | name , plan | next false unless plan . has_children? or plan . description next true if name =~ pattern next false unless plan . has_children? filter_plans ( pattern , plan . children ) plan . has_children? end end
Removes plans whose names don't match the given pattern from the tree.
Removes plans whose names don ' t match the given pattern from the tree .
# Don't display plans without a description or children
None
Void
pattern
the pattern to match against
the pattern to match against
plans
the plans to filter
the plans to filter