module BehaviorTree::Dsl::SpellChecker

Helpers for spellchecking, and correcting user input in the DSL builder.

Private Instance Methods

most_similar_name(name) click to toggle source
# File lib/behavior_tree/concerns/dsl/spell_checker.rb, line 15
def most_similar_name(name)
  return nil if (defined? DidYouMean).nil?

  DidYouMean::SpellChecker.new(dictionary: @node_type_mapping.keys)
                          .correct(name)&.first
end
raise_node_type_not_exists(missing_method) click to toggle source
# File lib/behavior_tree/concerns/dsl/spell_checker.rb, line 9
def raise_node_type_not_exists(missing_method)
  suggestion = most_similar_name missing_method
  method_alias = @node_type_mapping.dig suggestion, :alias
  raise NodeTypeDoesNotExistError.new(missing_method, suggestion, method_alias)
end