class Prism::Pack::Format
Результат разбора шаблона пакета.
Атрибуты
Список директив в шаблоне.
Кодировка шаблона.
Открытые методы класса
# File lib/prism/pack.rb, line 208 def initialize(directives, encoding) @directives = directives @encoding = encoding end
Создаёт новый Format с указанными директивами и кодировкой.
Открытые методы экземпляра
# File lib/prism/pack.rb, line 214
def describe
source_width = directives.map { |d| d.source.inspect.length }.max
directive_lines = directives.map do |directive|
if directive.type == SPACE
source = directive.source.inspect
else
source = directive.source
end
# @type var source_width: Integer
" #{source.ljust(source_width)} #{directive.describe}"
end
(["Directives:"] + directive_lines + ["Encoding:", " #{encoding}"]).join("\n")
end Возвращает понятное человеку описание формата.
Ruby Core © 1993–2025 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.