Module: BehaviorTree::Dsl::SpellChecker
- Included in:
- Builder
- Defined in:
- lib/behavior_tree/concerns/dsl/spell_checker.rb
Overview
Helpers for spellchecking, and correcting user input in the DSL builder.
Instance Method Summary collapse
Instance Method Details
#most_similar_name(name) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/behavior_tree/concerns/dsl/spell_checker.rb', line 13 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) ⇒ Object
7 8 9 10 11 |
# File 'lib/behavior_tree/concerns/dsl/spell_checker.rb', line 7 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 |