Class: WP2Middleman::Frontmatter
- Inherits:
-
Object
- Object
- WP2Middleman::Frontmatter
- Defined in:
- lib/wp2middleman/frontmatter.rb
Instance Method Summary collapse
-
#initialize(post, include_fields: []) ⇒ Frontmatter
constructor
A new instance of Frontmatter.
- #post_data ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(post, include_fields: []) ⇒ Frontmatter
Returns a new instance of Frontmatter.
5 6 7 8 |
# File 'lib/wp2middleman/frontmatter.rb', line 5 def initialize(post, include_fields: []) @post = post @include_fields = include_fields end |
Instance Method Details
#post_data ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/wp2middleman/frontmatter.rb', line 10 def post_data data = { 'title' => post.title, 'date' => post.date_time_published, 'tags' => post. } data['published'] = false if !post.published? include_fields.each do |field| data[field] = post.field(field) end data end |
#to_yaml ⇒ Object
26 27 28 |
# File 'lib/wp2middleman/frontmatter.rb', line 26 def to_yaml post_data.to_yaml.strip end |