Sha256: ce8afd186ff1e9053f1aeb1c0851fd67efba3f99246f895d1ac491ab5b17f3b8

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

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.7.0 lib/pdf/core/outline_item.rb