Class: Marko::Model::Markup

Inherits:
Object
  • Object
show all
Defined in:
lib/marko/model/markup.rb

Overview

Raw Markup

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, lineno, content) ⇒ Markup

Returns a new instance of Markup.



13
14
15
16
17
# File 'lib/marko/model/markup.rb', line 13

def initialize(filename, lineno, content)
  @filename = filename
  @lineno = lineno
  @content = content
end

Instance Attribute Details

#contentString (readonly)

Returns:



11
12
13
# File 'lib/marko/model/markup.rb', line 11

def content
  @content
end

#filenameString (readonly)

Returns:



7
8
9
# File 'lib/marko/model/markup.rb', line 7

def filename
  @filename
end

#linenoIntger (readonly)

Returns:

  • (Intger)


9
10
11
# File 'lib/marko/model/markup.rb', line 9

def lineno
  @lineno
end

Instance Method Details

#headerObject



19
20
21
# File 'lib/marko/model/markup.rb', line 19

def header
  @content.lines.first
end

#levelObject



23
24
25
# File 'lib/marko/model/markup.rb', line 23

def level
  header.scan(/^#+/).first&.size
end

#to_sObject



27
28
29
# File 'lib/marko/model/markup.rb', line 27

def to_s
  "#{filename}:#{lineno.to_s.rjust(2,'0')} >> #{header}".strip
end