Class: Lookbook::FrontmatterExtractor
- Defined in:
- lib/lookbook/services/templates/frontmatter_extractor.rb
Constant Summary collapse
- FRONTMATTER_REGEX =
/\A---(.|\n)*?---/
Instance Attribute Summary collapse
- #content ⇒ Object readonly
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(content) ⇒ FrontmatterExtractor
constructor
A new instance of FrontmatterExtractor.
Methods inherited from Service
Constructor Details
#initialize(content) ⇒ FrontmatterExtractor
Returns a new instance of FrontmatterExtractor.
7 8 9 |
# File 'lib/lookbook/services/templates/frontmatter_extractor.rb', line 7 def initialize(content) @content = content.to_s end |
Instance Attribute Details
#content ⇒ Object (readonly)
5 6 7 |
# File 'lib/lookbook/services/templates/frontmatter_extractor.rb', line 5 def content @content end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 |
# File 'lib/lookbook/services/templates/frontmatter_extractor.rb', line 11 def call frontmatter = extract_frontmatter(content) rest = strip_frontmatter(content) [frontmatter, rest] end |