Sha256: 2b1b8f7deff4d5c923abd3f38699716cfce7a7299444b2ead1c21dfee4e345d0

Contents?: true

Size: 664 Bytes

Versions: 43

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

class String
  def pred
    # integers
    (Integer self).pred.to_s
  rescue ::ArgumentError
    # chars (upper alpha, lower alpha, lower greek)
    ([65, 97, 945].include? ord) ? '0' : ([ord - 1].pack 'U1')
  end

  # If the string is ASCII only, convert it to a PDF LiteralString object. Otherwise, return self.
  def as_pdf
    ascii_only? ? (::PDF::Core::LiteralString.new encode ::Encoding::ASCII_8BIT) : self
  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_object
    ::PDF::Core.pdf_object as_pdf
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
asciidoctor-pdf-2.3.19 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.18 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.17 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.16 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.15 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.14 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.13 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.12 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.11 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.10 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.9 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.8 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.7 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.6 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.5 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.4 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.3 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.2 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.1 lib/asciidoctor/pdf/ext/core/string.rb
asciidoctor-pdf-2.3.0 lib/asciidoctor/pdf/ext/core/string.rb