class Prism::Pack::Format
The result of parsing a pack template.
Attributes
A list of the directives in the template.
The encoding of the template.
Public Class Methods
Source
# File lib/prism/pack.rb, line 206 def initialize(directives, encoding) @directives = directives @encoding = encoding end
Create a new Format with the given directives and encoding.
Public Instance Methods
Source
# File lib/prism/pack.rb, line 212
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 Provide a human-readable description of the format.
Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.