Class: Mailto::Frontmatter

Inherits:
Object
  • Object
show all
Defined in:
lib/mailto.rb

Constant Summary collapse

DELIMITER =
"---".freeze
NEWLINE =
/\r\n?|\n/.freeze
PATTERN =
/\A(#{DELIMITER}#{NEWLINE}(.+?)#{NEWLINE}#{DELIMITER}#{NEWLINE}*)?(.+)\Z/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Frontmatter

Returns a new instance of Frontmatter.



12
13
14
# File 'lib/mailto.rb', line 12

def initialize(content)
  _, @data, @body = content.match(PATTERN).captures
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/mailto.rb', line 10

def body
  @body
end

Instance Method Details

#dataObject



16
17
18
# File 'lib/mailto.rb', line 16

def data
  @data ? YAML.load(@data) : {}
end