Class: Mkmatter::Answers
- Inherits:
-
Object
- Object
- Mkmatter::Answers
- Defined in:
- lib/mkmatter/answers.rb
Instance Attribute Summary collapse
-
#answer_hash ⇒ Object
Returns the value of attribute answer_hash.
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#date ⇒ Object
Returns the value of attribute date.
-
#draft ⇒ Object
Returns the value of attribute draft.
-
#extra_fields ⇒ Object
Returns the value of attribute extra_fields.
-
#file_format ⇒ Object
Returns the value of attribute file_format.
-
#matter ⇒ Object
Returns the value of attribute matter.
-
#published ⇒ Object
Returns the value of attribute published.
-
#slug_date ⇒ Object
Returns the value of attribute slug_date.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(question_hash, publish) ⇒ Answers
constructor
A new instance of Answers.
Constructor Details
#initialize(question_hash, publish) ⇒ Answers
Returns a new instance of Answers.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mkmatter/answers.rb', line 13 def initialize(question_hash, publish) @title = question_hash[:title] @tags = question_hash[:tags] @categories = question_hash[:categories] Time.zone = question_hash[:time_zone] now = Time.zone.now @date = now.to_s @slug_date = now.strftime('%Y-%m-%d') @published = publish @file_format = question_hash[:file_format] @extra_fields = question_hash[:extra_fields] @matter = { layout: question_hash[:layout], title: @title, categories: @categories, tags: @tags, date: @date, } if @extra_fields @matter.merge!(@extra_fields) end @matter[:published] = @published if publish end |
Instance Attribute Details
#answer_hash ⇒ Object
Returns the value of attribute answer_hash.
8 9 10 |
# File 'lib/mkmatter/answers.rb', line 8 def answer_hash @answer_hash end |
#categories ⇒ Object
Returns the value of attribute categories.
6 7 8 |
# File 'lib/mkmatter/answers.rb', line 6 def categories @categories end |
#date ⇒ Object
Returns the value of attribute date.
7 8 9 |
# File 'lib/mkmatter/answers.rb', line 7 def date @date end |
#draft ⇒ Object
Returns the value of attribute draft.
7 8 9 |
# File 'lib/mkmatter/answers.rb', line 7 def draft @draft end |
#extra_fields ⇒ Object
Returns the value of attribute extra_fields.
11 12 13 |
# File 'lib/mkmatter/answers.rb', line 11 def extra_fields @extra_fields end |
#file_format ⇒ Object
Returns the value of attribute file_format.
9 10 11 |
# File 'lib/mkmatter/answers.rb', line 9 def file_format @file_format end |
#matter ⇒ Object
Returns the value of attribute matter.
10 11 12 |
# File 'lib/mkmatter/answers.rb', line 10 def matter @matter end |
#published ⇒ Object
Returns the value of attribute published.
9 10 11 |
# File 'lib/mkmatter/answers.rb', line 9 def published @published end |
#slug_date ⇒ Object
Returns the value of attribute slug_date.
8 9 10 |
# File 'lib/mkmatter/answers.rb', line 8 def slug_date @slug_date end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/mkmatter/answers.rb', line 6 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/mkmatter/answers.rb', line 6 def title @title end |