class YARP::Pack::Format

Attributes

directives[R]
encoding[R]

Public Class Methods

new(directives, encoding) click to toggle source
# File yarp/pack.rb, line 165
def initialize(directives, encoding)
  @directives = directives
  @encoding = encoding
end

Public Instance Methods

describe() click to toggle source
# File yarp/pack.rb, line 170
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