class Tufte::Post
Attributes
slug[R]
title[R]
Public Class Methods
load(filename)
click to toggle source
# File lib/tufte/post.rb, line 31 def self.load(filename) file_contents = File.read(filename) metadata = YAML.load(file_contents) new( date: metadata.fetch("date"), title: metadata.fetch("title"), slug: File.basename(filename, ".yml"), raw_body: file_contents.split("---\n", 3).last, ) end
new(date:, title:, slug:, raw_body:)
click to toggle source
# File lib/tufte/post.rb, line 7 def initialize(date:, title:, slug:, raw_body:) @date = date @slug = slug @title = title @raw_body = raw_body end
Public Instance Methods
body()
click to toggle source
# File lib/tufte/post.rb, line 14 def body rendered_erb = Tufte.render(@raw_body, :@post => self) Markdown.new(rendered_erb).to_html end
date()
click to toggle source
# File lib/tufte/post.rb, line 19 def date @date.strftime("%Y %b %-d") end
output_directory()
click to toggle source
# File lib/tufte/post.rb, line 23 def output_directory File.join(@date.year.to_s, @date.month.to_s, @date.day.to_s, slug) end
output_filename()
click to toggle source
# File lib/tufte/post.rb, line 27 def output_filename File.join(output_directory, "index.html") end