Class
The result of parsing a pack template.
Attributes
Read
A list of the directives in the template.
Read
The encoding of the template.
Class Methods
lib/prism/pack.rb
View on GitHub
# File tmp/rubies/ruby-3.3.0/lib/prism/pack.rb, line 203
def initialize(directives, encoding)
@directives = directives
@encoding = encoding
end
Create a new Format
with the given directives and encoding.
Instance Methods
#
lib/prism/pack.rb
View on GitHub
# File tmp/rubies/ruby-3.3.0/lib/prism/pack.rb, line 209
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
" #{source.ljust(source_width)} #{directive.describe}"
end
(["Directives:"] + directive_lines + ["Encoding:", " #{encoding}"]).join("\n")
end
Provide a human-readable description of the format.