Class: Paperdragon::Metadata

Inherits:
Hash
  • Object
show all
Defined in:
lib/paperdragon/metadata.rb

Overview

2-level meta data hash for a file. Returns empty string if not found. Metadata.new(nil)[:width] => “” Holds metadata for an attachment. This is a hash keyed by versions, e.g. :original, :thumb, and so on.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](hash) ⇒ Object

allow Metadata



7
8
9
# File 'lib/paperdragon/metadata.rb', line 7

def self.[](hash) # allow Metadata[nil]
  super hash || {}
end

Instance Method Details

#[](name) ⇒ Object



11
12
13
# File 'lib/paperdragon/metadata.rb', line 11

def [](name)
  super || {}
end

#populated?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/paperdragon/metadata.rb', line 15

def populated?
  size > 0
end

#to_hashObject

Consider this semi-public. This is used the make the metadata hash serialisable (as a plain hash).



20
21
22
# File 'lib/paperdragon/metadata.rb', line 20

def to_hash
  Hash[self]
end