Class: Mailto::Frontmatter
- Inherits:
-
Object
- Object
- Mailto::Frontmatter
- 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
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(content) ⇒ Frontmatter
constructor
A new instance of Frontmatter.
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
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/mailto.rb', line 10 def body @body end |
Instance Method Details
#data ⇒ Object
16 17 18 |
# File 'lib/mailto.rb', line 16 def data @data ? YAML.load(@data) : {} end |