Class: Hellm::MarkdownFile
- Inherits:
-
Object
- Object
- Hellm::MarkdownFile
- Defined in:
- lib/hellm/markdown_file.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#content ⇒ Object
Returns the value of attribute content.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/hellm/markdown_file.rb', line 4 def attributes @attributes end |
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/hellm/markdown_file.rb', line 4 def content @content end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/hellm/markdown_file.rb', line 4 def path @path end |
Class Method Details
.read(path) ⇒ Object
6 7 8 9 10 |
# File 'lib/hellm/markdown_file.rb', line 6 def self.read(path) file = new(path) file.read file end |
Instance Method Details
#fetch(key, default = nil) ⇒ Object
12 13 14 |
# File 'lib/hellm/markdown_file.rb', line 12 def fetch(key, default=nil) attributes.fetch(key.to_s, default) end |
#read ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/hellm/markdown_file.rb', line 16 def read file = File.read(path) frontmatter, content = separate_frontmatter_and_content(file) self.attributes = YAML.load(frontmatter) if frontmatter != "" self.attributes ||= {} self.content = content self end |