Class: Fleakr::Objects::MetadataCollection
- Inherits:
-
Object
- Object
- Fleakr::Objects::MetadataCollection
- Includes:
- Enumerable
- Defined in:
- lib/fleakr/objects/metadata_collection.rb
Instance Attribute Summary collapse
-
#photo ⇒ Object
readonly
Returns the value of attribute photo.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #data ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(photo) ⇒ MetadataCollection
constructor
A new instance of MetadataCollection.
- #keys ⇒ Object
Constructor Details
#initialize(photo) ⇒ MetadataCollection
Returns a new instance of MetadataCollection.
10 11 12 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 10 def initialize(photo) @photo = photo end |
Instance Attribute Details
#photo ⇒ Object (readonly)
Returns the value of attribute photo.
8 9 10 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 8 def photo @photo end |
Instance Method Details
#[](key) ⇒ Object
25 26 27 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 25 def [](key) data[key].raw end |
#data ⇒ Object
14 15 16 17 18 19 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 14 def data @data ||= begin elements = Metadata.find_all_by_photo_id(photo.id) elements.inject({}) {|c, e| c.merge(e.label => e) } end end |
#each(&block) ⇒ Object
29 30 31 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 29 def each(&block) data.each(&block) end |
#keys ⇒ Object
21 22 23 |
# File 'lib/fleakr/objects/metadata_collection.rb', line 21 def keys data.keys end |