Class: Drift::BlogPostBase
- Inherits:
-
StaticModel
- Object
- StaticModel
- Drift::BlogPostBase
- Defined in:
- lib/drift/blog_post_base.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.markup_ext ⇒ Object
Returns the value of attribute markup_ext.
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#content ⇒ Object
Returns the value of attribute content.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .find_by_slug(slug) ⇒ Object
- .parse_datetime_from_filename(filename) ⇒ Object
- .parse_slug_from_filename(filename) ⇒ Object
- .source ⇒ Object
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ BlogPostBase
constructor
A new instance of BlogPostBase.
Methods inherited from StaticModel
Constructor Details
#initialize(args = {}) ⇒ BlogPostBase
Returns a new instance of BlogPostBase.
33 34 35 36 |
# File 'lib/drift/blog_post_base.rb', line 33 def initialize(args = {}) super set_attributes_from_filename(args[:file]) unless args[:file].nil? end |
Class Attribute Details
.markup_ext ⇒ Object
Returns the value of attribute markup_ext.
4 5 6 |
# File 'lib/drift/blog_post_base.rb', line 4 def markup_ext @markup_ext end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def @author end |
#content ⇒ Object
Returns the value of attribute content.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def content @content end |
#created_at ⇒ Object
Returns the value of attribute created_at.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def created_at @created_at end |
#slug ⇒ Object
Returns the value of attribute slug.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def slug @slug end |
#title ⇒ Object
Returns the value of attribute title.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
31 32 33 |
# File 'lib/drift/blog_post_base.rb', line 31 def version @version end |
Class Method Details
.find_by_slug(slug) ⇒ Object
14 15 16 17 18 |
# File 'lib/drift/blog_post_base.rb', line 14 def find_by_slug(slug) file = all_files.detect{ |f| slug == parse_slug_from_filename(f) } find_by_file(file) end |
.parse_datetime_from_filename(filename) ⇒ Object
20 21 22 23 24 |
# File 'lib/drift/blog_post_base.rb', line 20 def parse_datetime_from_filename(filename) date = filename.split(/[_|\.]/)[0] time = filename.split(/[_|\.]/)[1] DateTime.parse "#{date} #{time[0..1]}:#{time[2..3]}:#{time[4..5]}" end |
.parse_slug_from_filename(filename) ⇒ Object
26 27 28 |
# File 'lib/drift/blog_post_base.rb', line 26 def parse_slug_from_filename(filename) filename.split(/[_|\.]/)[2] end |
.source ⇒ Object
6 7 8 |
# File 'lib/drift/blog_post_base.rb', line 6 def source @source ||= 'db/static/blog_posts' end |