Module PhotosHelper
In: app/helpers/photos_helper.rb

Methods

Public Instance methods

[Source]

    # File app/helpers/photos_helper.rb, line 7
 7:   def aspect(photo)
 8:     case 
 9:     when photo.vertical?
10:       "vertical"
11:     when photo.square?
12:       "square"
13:     else
14:       "horizontal"
15:     end
16:   end

[Source]

    # File app/helpers/photos_helper.rb, line 29
29:   def photo_height(photo, size)
30:     if photo.height.present?
31:       size = size.to_s.gsub(/[^\d]/, '').to_f 
32:       if photo.vertical?
33:         height = size.to_i
34:       else
35:         height = (size/photo.aspect).round
36:       end
37:     end
38:   end

[Source]

    # File app/helpers/photos_helper.rb, line 18
18:   def photo_width(photo, size)
19:     if photo.width.present?
20:       size = size.to_s.gsub(/[^\d]/, '').to_f 
21:       if photo.horizontal?
22:         width = size.to_i
23:       else
24:         width = (size*photo.aspect).round
25:       end
26:     end
27:   end

[Source]

   # File app/helpers/photos_helper.rb, line 2
2:   def shorten(title, length=65)
3:     # We use length-4 because are going to add "... "
4:     title.length > length ? "#{truncate(title, :length =>  length-4, :omission => "").sub(/[^\w]\w+$/, '')}... " : title
5:   end

[Validate]