Class: Marmerdo::MarkdownParser

Inherits:
Object
  • Object
show all
Defined in:
lib/marmerdo/markdown_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, content) ⇒ MarkdownParser

Returns a new instance of MarkdownParser.



7
8
9
10
# File 'lib/marmerdo/markdown_parser.rb', line 7

def initialize(path, content)
  @path = path
  @content = content
end

Instance Method Details

#parseNode?

Returns the parsed node or nil if the file has no marmerdo front matter.

Returns:

  • (Node, nil)

    the parsed node or nil if the file has no marmerdo front matter.



13
14
15
16
17
18
19
20
21
22
# File 'lib/marmerdo/markdown_parser.rb', line 13

def parse
  return nil unless marmerdo_file?

  Node.new(
    path: @path,
    name: marmerdo_matter["name"] || File.basename(@path, ".*"),
    namespace: marmerdo_matter["namespace"],
    relationships: relationships
  )
end