Class: ZIMG::PNG::Metadata

Inherits:
Array
  • Object
show all
Defined in:
lib/zimg/png/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(img = nil) ⇒ Metadata

Returns a new instance of Metadata.



6
7
8
9
10
11
12
13
14
15
# File 'lib/zimg/png/metadata.rb', line 6

def initialize(img = nil)
  super()
  return unless img

  img.chunks.each do |c|
    next unless c.is_a?(TextChunk)

    self << [c.keyword, c.text, c.to_hash]
  end
end

Instance Method Details

#[](*args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/zimg/png/metadata.rb', line 17

def [] *args
  if args.first.is_a?(String)
    each { |a| return a[1] if a[0] == args.first }
    nil
  else
    super
  end
end