-
-
Save anonymous/ff9e556487ecf88a53e062d2fbea68d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post | |
@@posts ||= [] | |
attr_accessor :body, :header | |
def initialize (doc, slug) | |
self.header, self.body = doc.split("\n...\n") | |
self.header = YAML.load(header) | |
self.header['slug'] = slug + '.html' | |
@@posts << self | |
end | |
def all | |
@@posts | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def collect_files_from(dir) | |
files = Dir[dir+'*.text'] | |
files.each do |file| | |
slug = File.basename(file, ".text") | |
file = File.read(file) | |
return Post.new(file, slug) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment