Class: Lines::Article

Inherits:
ApplicationRecord show all
Extended by:
FriendlyId
Defined in:
app/models/lines/article.rb

Constant Summary collapse

HERO_IMAGES =

Predifined hero images. Images are loaded from the public/heroes directory

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hero_image_fileObject

Returns the value of attribute hero_image_file.



26
27
28
# File 'app/models/lines/article.rb', line 26

def hero_image_file
  @hero_image_file
end

Instance Method Details

#absolute_image_urlObject

Returns the absolute url for the hero image



70
71
72
# File 'app/models/lines/article.rb', line 70

def absolute_image_url
  absolute_url_for(image_url)
end

#image_urlObject

Returns the url for the hero image



65
66
67
# File 'app/models/lines/article.rb', line 65

def image_url
  image = self.hero_image? ? self.hero_image.url : self.short_hero_image
end

#short_hero_image_urlObject

Returns URL of selected image from HERO_IMAGES array



53
54
55
# File 'app/models/lines/article.rb', line 53

def short_hero_image_url
  "#{self.short_hero_image}"
end

#sub_titleObject

Returns value of subtitle



75
76
77
# File 'app/models/lines/article.rb', line 75

def sub_title
  read_attribute(:sub_title) || ''
end

#used_imagesObject

Returns array of images used in content



58
59
60
61
62
# File 'app/models/lines/article.rb', line 58

def used_images
  result = content.scan(/!\[.*\]\(.*\/image\/(\d.*)\/.*\)/)
  image_ids = result.nil? ? nil : result.map{ |i| i[0].to_i }.uniq
  image_ids
end