class Ernest::MetadataParser

Attributes

metadata[R]
text[R]

Public Class Methods

new(text) click to toggle source
# File lib/ernest/metadata_parser.rb, line 9
def initialize(text)
  @text = text
  @metadata = {}
end

Public Instance Methods

parse() click to toggle source
# File lib/ernest/metadata_parser.rb, line 14
def parse
  if @text =~ /^(---\s*\n.*?\n?^---\s*$\n?)/m
    @metadata = YAML.load($1)
    @text.sub!($1, '')
  end
  Data.new(metadata, text)
end