Class: BlogBoi::Article

Inherits:
ApplicationRecord show all
Defined in:
app/models/blog_boi/article.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#author_nameObject



44
45
46
# File 'app/models/blog_boi/article.rb', line 44

def author_name
  @author_name || author && author.name || nil
end

#category_namesObject



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_textObject



52
53
54
# File 'app/models/blog_boi/article.rb', line 52

def markdown_text
  Kramdown::Document.new(text).to_html
end

#read_timeObject

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