Spec-Zone.ru › Ruby 3.3

класс DidYouMean::VerboseFormatter

Родитель:
Объект

Это базовый, по умолчанию, форматтер для данного драгоценного камня. Форматтер отвечает на метод 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. Этот форматтер разработан, чтобы быть менее подробным, чтобы не занимать слишком много места на экране, но при этом быть достаточно полезным для пользователя.

@пример

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–2022 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.

Spec-Zone.ru

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