Class: Tocer::Parsers::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/tocer/parsers/header.rb

Overview

Represents a Markdown header.

Constant Summary collapse

PUNCTUATION =
"#"

Instance Method Summary collapse

Constructor Details

#initialize(markdown) ⇒ Header

Returns a new instance of Header.



9
10
11
# File 'lib/tocer/parsers/header.rb', line 9

def initialize markdown
  @markdown = markdown
end

Instance Method Details

#contentObject



17
18
19
# File 'lib/tocer/parsers/header.rb', line 17

def content
  markdown[prefix.length + 1, markdown.length].strip
end

#prefixObject



13
14
15
# File 'lib/tocer/parsers/header.rb', line 13

def prefix
  String markdown[/#{PUNCTUATION}{1,}/]
end