class Utopia::Gallery::Media

Represents a single unit of media, e.g. a video or image.

Constants

ORDER_KEY

Attributes

metadata[R]
path[R]

Public Class Methods

new(path, metadata) click to toggle source

@param path [String] The full path to the media asset.

# File lib/utopia/gallery/media.rb, line 26
def initialize(path, metadata)
        @path = path
        @metadata = metadata
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/utopia/gallery/media.rb, line 48
def <=> other
        if a = self[ORDER_KEY] and b = other[ORDER_KEY]
                a <=> b
        else
                self.path <=> other.path
        end
end
[](key) click to toggle source
# File lib/utopia/gallery/media.rb, line 34
def [] key
        @metadata[key.to_s]
end
caption() click to toggle source
# File lib/utopia/gallery/media.rb, line 38
def caption
        @metadata['caption']
end
to_s() click to toggle source
# File lib/utopia/gallery/media.rb, line 42
def to_s
        caption || File.basename(@path, ".*")
end