Class: BlogBoi::Article
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- BlogBoi::Article
- Defined in:
- app/models/blog_boi/article.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#author_name ⇒ Object
44 45 46 |
# File 'app/models/blog_boi/article.rb', line 44 def @author_name || && .name || nil end |
#category_names ⇒ Object
48 49 50 |
# File 'app/models/blog_boi/article.rb', line 48 def category_names @category_names || categories.pluck(:name).join(', ') end |
Instance Method Details
#markdown_text ⇒ Object
52 53 54 |
# File 'app/models/blog_boi/article.rb', line 52 def markdown_text Kramdown::Document.new(text).to_html end |
#read_time ⇒ Object
Methods
34 35 36 37 38 39 40 41 42 |
# File 'app/models/blog_boi/article.rb', line 34 def read_time length = (self.text.split.length / 200.0).ceil.to_s if length != '1' length + " minutes" else length + " minute" end end |