Class: MarkdownMetrics::LowElementsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_metrics/low_elements_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:) ⇒ LowElementsParser

Returns a new instance of LowElementsParser.



5
6
7
8
# File 'lib/markdown_metrics/low_elements_parser.rb', line 5

def initialize(value:)
  @value = value
  @elements = []
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



3
4
5
# File 'lib/markdown_metrics/low_elements_parser.rb', line 3

def elements
  @elements
end

Instance Method Details

#parseObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/markdown_metrics/low_elements_parser.rb', line 10

def parse
  @value.each_character_with_index do |chr, index|
    element = initialize_element(chr, index)
    @elements << {
      name: element.name,
      value: element.value
    }.merge(element.attributes)
    
    throw :skip_iteration, element.skip_lines_until if element.skip_lines_until > 0
  end
end