Class: Utopia::Gallery::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/gallery/media.rb

Overview

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

Constant Summary collapse

ORDER_KEY =
'order'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, metadata) ⇒ Media

Returns a new instance of Media.

Parameters:

  • path (String)

    The full path to the media asset.



26
27
28
29
# File 'lib/utopia/gallery/media.rb', line 26

def initialize(path, )
  @path = path
   = 
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



32
33
34
# File 'lib/utopia/gallery/media.rb', line 32

def 
  
end

#pathObject (readonly)

Returns the value of attribute path.



31
32
33
# File 'lib/utopia/gallery/media.rb', line 31

def path
  @path
end

Instance Method Details

#<=>(other) ⇒ Object



48
49
50
51
52
53
54
# 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.last <=> other.path.last
  end
end

#[](key) ⇒ Object



34
35
36
# File 'lib/utopia/gallery/media.rb', line 34

def [] key
  [key.to_s]
end

#captionObject



38
39
40
# File 'lib/utopia/gallery/media.rb', line 38

def caption
  ['caption']
end

#to_sObject



42
43
44
# File 'lib/utopia/gallery/media.rb', line 42

def to_s
  caption || File.basename(@path, ".*")
end