Class: Ernest::MetadataParser
- Inherits:
-
Object
- Object
- Ernest::MetadataParser
- Defined in:
- lib/ernest/metadata_parser.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ MetadataParser
constructor
A new instance of MetadataParser.
- #parse ⇒ Object
Constructor Details
#initialize(text) ⇒ MetadataParser
Returns a new instance of MetadataParser.
9 10 11 12 |
# File 'lib/ernest/metadata_parser.rb', line 9 def initialize(text) @text = text @metadata = {} end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/ernest/metadata_parser.rb', line 7 def @metadata end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/ernest/metadata_parser.rb', line 7 def text @text end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 |
# 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(, text) end |