Spec-Zone.ru › Ruby 3.4
  1. DidYouMean::
  2. VerboseFormatter

класс DidYouMean::VerboseFormatter

Родительский класс:
Object

DidYouMean::Formatter — это базовый форматтер, используемый в gem по умолчанию. Форматтер поддерживает метод message_for и возвращает удобочитаемую строку.

Общедоступные методы класса

message_for (corrections) Показать исходный код
# File lib/did_you_mean/formatter.rb, line 29
def self.message_for(corrections)
  corrections.empty? ? "" : "\nDid you mean?  #{corrections.join("\n               ")}"
end

Возвращает удобочитаемую строку, содержащую corrections. Этот форматтер разработан так, чтобы быть менее многословным и не занимать слишком много места на экране, оставаясь при этом достаточно полезным для пользователя.

@example

formatter = DidYouMean::Formatter.new

# displays suggestions in two lines with the leading empty line
puts formatter.message_for(["methods", "method"])

Did you mean?  methods
                method
# => nil

# displays an empty line
puts formatter.message_for([])

# => nil

Общедоступные методы экземпляра

message_for (corrections) Показать исходный код
# File lib/did_you_mean/formatter.rb, line 33
def message_for(corrections)
  warn "The instance method #message_for has been deprecated. Please use the class method " \
       "DidYouMean::Formatter.message_for(...) instead."

  self.class.message_for(corrections)
end

Ruby Core © 1993–2025 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API