Class: ImageSite::Image
- Inherits:
-
Model
- Object
- Model
- ImageSite::Image
show all
- Defined in:
- lib/image_site/image.rb
Constant Summary
collapse
- NEWLINE =
"\xE2\x80\xA8".force_encoding('ASCII-8BIT')
Instance Attribute Summary collapse
Attributes inherited from Model
#number
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
#make_subdir, template, #write_html
Constructor Details
#initialize(number, file, options) ⇒ Image
Returns a new instance of Image.
30
31
32
33
|
# File 'lib/image_site/image.rb', line 30
def initialize(number, file, options)
super number, options
@file = file
end
|
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
28
29
30
|
# File 'lib/image_site/image.rb', line 28
def index
@index
end
|
#next ⇒ Object
Returns the value of attribute next.
28
29
30
|
# File 'lib/image_site/image.rb', line 28
def next
@next
end
|
#previous ⇒ Object
Returns the value of attribute previous.
28
29
30
|
# File 'lib/image_site/image.rb', line 28
def previous
@previous
end
|
Class Method Details
.all(options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/image_site/image.rb', line 9
def self.all(options)
images = options.files.map.with_index(1) do |file, i|
Image.new i, file, options
end
images.each.with_index do |image, i|
if i > 0
image.previous = images[i - 1]
end
if i < images.length - 1
image.next = images[i + 1]
end
end
end
|
Instance Method Details
#description ⇒ Object
51
52
53
|
# File 'lib/image_site/image.rb', line 51
def description
exif && exif.image_description && exif.image_description.gsub(NEWLINE, "<br/>\n").force_encoding('utf-8')
end
|
#relative_html ⇒ Object
59
60
61
|
# File 'lib/image_site/image.rb', line 59
def relative_html
"Pages/#{@number}.html"
end
|
#relative_image ⇒ Object
40
41
42
|
# File 'lib/image_site/image.rb', line 40
def relative_image
"Images/#{@number}.jpeg"
end
|
#relative_thumbnail ⇒ Object
67
68
69
|
# File 'lib/image_site/image.rb', line 67
def relative_thumbnail
"Thumbnails/#{@number}.jpeg"
end
|
55
56
57
|
# File 'lib/image_site/image.rb', line 55
def tags
dc(:subject) || []
end
|
#title ⇒ Object
44
45
46
47
|
# File 'lib/image_site/image.rb', line 44
def title
title = dc(:title)
title && title.first || nil
end
|
#write ⇒ Object
35
36
37
38
|
# File 'lib/image_site/image.rb', line 35
def write
write_scaled_image relative_image, 912
write_html image: self
end
|
#write_thumbnail ⇒ Object
63
64
65
|
# File 'lib/image_site/image.rb', line 63
def write_thumbnail
write_scaled_image relative_thumbnail, 240
end
|