Class: Lookbook::FrontmatterExtractor

Inherits:
Service
  • Object
show all
Defined in:
lib/lookbook/services/templates/frontmatter_extractor.rb

Constant Summary collapse

FRONTMATTER_REGEX =
/\A---(.|\n)*?---/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

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

#contentObject (readonly)



5
6
7
# File 'lib/lookbook/services/templates/frontmatter_extractor.rb', line 5

def content
  @content
end

Instance Method Details

#callObject



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