Class: RGallery::Photo

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-gallery/rgallery/photo.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ Photo

Returns a new instance of Photo.



5
6
7
8
# File 'lib/rails-gallery/rgallery/photo.rb', line 5

def initialize id, options = {}
  @id = id
  @options = options
end

Class Attribute Details

.extensionObject



45
46
47
# File 'lib/rails-gallery/rgallery/photo.rb', line 45

def extension
  @extension ||= :png
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/rails-gallery/rgallery/photo.rb', line 3

def id
  @id
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/rails-gallery/rgallery/photo.rb', line 3

def options
  @options
end

Instance Method Details

#altObject



30
31
32
# File 'lib/rails-gallery/rgallery/photo.rb', line 30

def alt
  'no alt'
end

#descriptionObject



34
35
36
# File 'lib/rails-gallery/rgallery/photo.rb', line 34

def description
  'no description'
end

#extensionObject



38
39
40
# File 'lib/rails-gallery/rgallery/photo.rb', line 38

def extension
  options[:extension] || self.class.extension
end

#file_pathObject



14
15
16
# File 'lib/rails-gallery/rgallery/photo.rb', line 14

def file_path
  "#{filename}.#{extension}"
end

#filenameObject



10
11
12
# File 'lib/rails-gallery/rgallery/photo.rb', line 10

def filename
  id
end

#pathObject



18
19
20
# File 'lib/rails-gallery/rgallery/photo.rb', line 18

def path
  file_path
end

#thumbObject



22
23
24
# File 'lib/rails-gallery/rgallery/photo.rb', line 22

def thumb
  path
end

#titleObject



26
27
28
# File 'lib/rails-gallery/rgallery/photo.rb', line 26

def title
  'no title'
end