Class: Lines::Article
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Lines::Article
- 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
-
#hero_image_file ⇒ Object
Returns the value of attribute hero_image_file.
Instance Method Summary collapse
-
#image_url ⇒ Object
Returns the url for the hero image.
-
#short_hero_image_url ⇒ Object
Returns URL of selected image from HERO_IMAGES array.
-
#sub_title ⇒ Object
Returns value of subtitle.
-
#used_images ⇒ Object
Returns array of images used in content.
Instance Attribute Details
#hero_image_file ⇒ Object
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
#image_url ⇒ Object
Returns the url for the hero image
65 66 67 |
# File 'app/models/lines/article.rb', line 65 def image_url self.hero_image? ? self.hero_image.url : self.short_hero_image end |
#short_hero_image_url ⇒ Object
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_title ⇒ Object
Returns value of subtitle
70 71 72 |
# File 'app/models/lines/article.rb', line 70 def sub_title read_attribute(:sub_title) || '' end |
#used_images ⇒ Object
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 |