Sha256: 69cf145eb9e1f33f5a9cf2822c62763778b439139a4093cad986c259f51a3b4e

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

module PDF
  module Core
    class OutlineItem #:nodoc:
      attr_accessor :count, :first, :last, :next, :prev, :parent, :title, :dest,
        :closed

      def initialize(title, parent, options)
        @closed = options[:closed]
        @title = title
        @parent = parent
        @count = 0
      end

      def to_hash
        hash = {
          Title: title,
          Parent: parent,
          Count: closed ? -count : count
        }
        [
          { First: first }, { Last: last }, { Next: defined?(@next) && @next },
          { Prev: prev }, { Dest: dest }
        ].each do |h|
          unless h.values.first.nil?
            hash.merge!(h)
          end
        end
        hash
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdf-core-0.8.1 lib/pdf/core/outline_item.rb