Sha256: 8d15b967f087f357da2c6597c44232d3107c85257ae3385c6e572b8b9ab9ac94

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

class String
  def pred
    begin
      # integers
      %(#{(Integer self) - 1})
    rescue ::ArgumentError
      # chars (upper alpha, lower alpha, lower greek)
      ([65, 97, 945].include? ord) ? '0' : ([ord - 1].pack 'U*')
    end
  end unless method_defined? :pred

  # If the string is ASCII only, convert it to a PDF LiteralString object. Otherwise, return self.
  def as_pdf
    if ascii_only?
      ::PDF::Core::LiteralString.new(encode ::Encoding::ASCII_8BIT)
    else
      self
    end
  end

  # Convert the string to a serialized PDF object. If the string can be encoded as ASCII-8BIT, first convert it to a PDF
  # LiteralString object.
  def to_pdf
    ::PDF::Core::PdfObject as_pdf
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
asciidoctor-pdf-1.5.0.alpha.14 lib/asciidoctor-pdf/core_ext/string.rb