Sha256: 21780d71103b344e8ec2b5d596ba990ac662606ef872b5eacb037876c12146d5
Contents?: true
Size: 604 Bytes
Versions: 1
Compression:
Stored size: 604 Bytes
Contents
module PageViewer class Page attr_reader :root, :name, :headers, :body def self.path(root, name) File.join(root, name + '.md') end def initialize(root, name) @root = root @name = name parse_page end def parse_page if contents =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)(.*)/m @headers = YAML.load($1) @body = $3 else @headers = {} @body = contents end end def contents @contents ||= File.open(self.class.path(root, name), 'r:utf-8') do |file| file.read end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
page_viewer-0.0.5 | lib/page_viewer/page.rb |