Class: Omnom::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/omnom/post.rb

Instance Method Summary collapse

Instance Method Details

#clean_urlsObject



20
21
22
23
24
25
# File 'app/models/omnom/post.rb', line 20

def clean_urls
  [:author_url, :comments_url, :thumbnail_url, :url].each do |attribute|
    value = send(attribute)
    send("#{attribute}=", Omnom::Utils.clean_url(value)) if value.present?
  end
end

#set_thumbnail_sizeObject



27
28
29
30
31
32
# File 'app/models/omnom/post.rb', line 27

def set_thumbnail_size
  return if thumbnail_url.blank?
  size = FastImage.size(thumbnail_url)
  return if size.blank?
  self.thumbnail_width, self.thumbnail_height = size
end

#sourceObject



43
44
45
# File 'app/models/omnom/post.rb', line 43

def source
  posts_origins.first.source
end

#truncate_fieldsObject



34
35
36
37
38
39
40
41
# File 'app/models/omnom/post.rb', line 34

def truncate_fields
  fields = [:title, :subtitle]
  fields.each do |field|
    value = send(field)
    next if value.nil?
    send("#{field}=", value.truncate(255))
  end
end