Class: GithubToCanvasQuiz::Parser::Markdown::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/github_to_canvas_quiz/parser/markdown/base.rb

Direct Known Subclasses

Question, Quiz

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(markdown) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
# File 'lib/github_to_canvas_quiz/parser/markdown/base.rb', line 9

def initialize(markdown)
  # Separate the frontmatter and the rest of the markdown content
  parsed = if Pathname(markdown).exist?
             FrontMatterParser::Parser.parse_file(markdown)
           else
             FrontMatterParser::Parser.new(:md).call(markdown)
           end
  @frontmatter = parsed.front_matter
  @markdown = parsed.content
end

Instance Attribute Details

#frontmatterObject (readonly)

Returns the value of attribute frontmatter.



7
8
9
# File 'lib/github_to_canvas_quiz/parser/markdown/base.rb', line 7

def frontmatter
  @frontmatter
end

#markdownObject (readonly)

Returns the value of attribute markdown.



7
8
9
# File 'lib/github_to_canvas_quiz/parser/markdown/base.rb', line 7

def markdown
  @markdown
end