Class: PointBlank::Parsing::ATXParser Abstract

Inherits:
NullParser
  • Object
show all
Defined in:
lib/mmmd/blankshell.rb

Overview

This class is abstract.

ATX heading

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NullParser

#close, #parsed_content

Constructor Details

#initializeATXParser

Returns a new instance of ATXParser.



419
420
421
422
# File 'lib/mmmd/blankshell.rb', line 419

def initialize
  super
  @matched = false
end

Class Attribute Details

.levelObject

Returns the value of attribute level.



411
412
413
# File 'lib/mmmd/blankshell.rb', line 411

def level
  @level
end

Class Method Details

.begin?(line) ⇒ Boolean

Returns:

  • (Boolean)


414
415
416
# File 'lib/mmmd/blankshell.rb', line 414

def begin?(line)
  line.match?(/^ {0,3}\#{#{@level}}(?: .*|)$/)
end

Instance Method Details

#consume(line, _parent, **_hargs) ⇒ Array(String, Boolean)

Consume line markers

Parameters:

  • line (String)

Returns:

  • (Array(String, Boolean))


425
426
427
428
429
430
431
432
433
# File 'lib/mmmd/blankshell.rb', line 425

def consume(line, _parent, **_hargs)
  return [nil, false] if @matched

  @matched = true
  push(line
    .gsub(/\A {0,3}\#{#{self.class.level}} */, '')
    .gsub(/( #+|)\Z/, ''))
  [line, false]
end