Permalink
Browse files

Be gone with you, vile instance variables

  • Loading branch information...
1 parent 4a87343 commit a1682634161f4e51374b48558520fcae1b7a9ec4 @practicingruby practicingruby committed May 8, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/jackal/page.rb
View
@@ -3,22 +3,24 @@
module Jackal
class Page
def initialize(source_file)
- @filename = File.basename(source_file)
+ self.filename = File.basename(source_file)
read_page(source_file)
end
- attr_reader :content, :filename, :metadata, :contents
+ attr_reader :filename, :metadata, :contents
private
+ attr_writer :filename, :metadata, :contents
+
def read_page(filename)
@contents = File.read(filename)
begin
- if (md = @contents.match(/^(?<headers>---\s*\n.*?\n?)^(---\s*$\n?)/m))
- @contents = md.post_match
- @metadata = YAML.load(md[:headers])
+ if (md = contents.match(/^(?<headers>---\s*\n.*?\n?)^(---\s*$\n?)/m))
+ self.contents = md.post_match
+ self.metadata = YAML.load(md[:headers])
end
rescue => e
puts "YAML Exception reading #{filename}: #{e.message}"

0 comments on commit a168263

Please sign in to comment.