Class: Mkmatter::Answers

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_hashObject

Returns the value of attribute answer_hash.



8
9
10
# File 'lib/mkmatter/answers.rb', line 8

def answer_hash
  @answer_hash
end

#categoriesObject

Returns the value of attribute categories.



6
7
8
# File 'lib/mkmatter/answers.rb', line 6

def categories
  @categories
end

#dateObject

Returns the value of attribute date.



7
8
9
# File 'lib/mkmatter/answers.rb', line 7

def date
  @date
end

#draftObject

Returns the value of attribute draft.



7
8
9
# File 'lib/mkmatter/answers.rb', line 7

def draft
  @draft
end

#extra_fieldsObject

Returns the value of attribute extra_fields.



11
12
13
# File 'lib/mkmatter/answers.rb', line 11

def extra_fields
  @extra_fields
end

#file_formatObject

Returns the value of attribute file_format.



9
10
11
# File 'lib/mkmatter/answers.rb', line 9

def file_format
  @file_format
end

#matterObject

Returns the value of attribute matter.



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

def matter
  @matter
end

#publishedObject

Returns the value of attribute published.



9
10
11
# File 'lib/mkmatter/answers.rb', line 9

def published
  @published
end

#slug_dateObject

Returns the value of attribute slug_date.



8
9
10
# File 'lib/mkmatter/answers.rb', line 8

def slug_date
  @slug_date
end

#tagsObject

Returns the value of attribute tags.



6
7
8
# File 'lib/mkmatter/answers.rb', line 6

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/mkmatter/answers.rb', line 6

def title
  @title
end