Class: EideticPDF::PdfObjects::PdfDictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/epdfo.rb

Direct Known Subclasses

PdfAnnotBorder, PdfURIAction, Trailer

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ PdfDictionary

Returns a new instance of PdfDictionary.



276
277
278
279
# File 'lib/epdfo.rb', line 276

def initialize(hash={})
  @hash = {}
  update(hash)
end

Instance Method Details

#[](key) ⇒ Object



281
282
283
# File 'lib/epdfo.rb', line 281

def [](key)
  @hash[name_from_key(key)]
end

#[]=(key, value) ⇒ Object



285
286
287
# File 'lib/epdfo.rb', line 285

def []=(key, value)
  @hash[name_from_key(key)] = value
end

#to_sObject



294
295
296
297
298
299
# File 'lib/epdfo.rb', line 294

def to_s
  s = "<<\n"
  # Sort the results consistently to be test-friendly.
  s << @hash.keys.sort { |a,b| a.to_s <=> b.to_s }.map { |key| "#{key}#{@hash[key]}\n" }.join
  s << ">>\n"
end

#update(other) ⇒ Object



289
290
291
292
# File 'lib/epdfo.rb', line 289

def update(other)
  other.each_pair { |key, value| self[key] = value }
  self
end