Class: MarkdownMetrics::TopElementsParser
- Inherits:
-
Object
- Object
- MarkdownMetrics::TopElementsParser
- Defined in:
- lib/markdown_metrics/top_elements_parser.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
-
#initialize(lines) ⇒ TopElementsParser
constructor
A new instance of TopElementsParser.
- #parse ⇒ Object
Constructor Details
#initialize(lines) ⇒ TopElementsParser
Returns a new instance of TopElementsParser.
5 6 7 8 |
# File 'lib/markdown_metrics/top_elements_parser.rb', line 5 def initialize(lines) @lines = lines @elements = [] end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
3 4 5 |
# File 'lib/markdown_metrics/top_elements_parser.rb', line 3 def elements @elements end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/markdown_metrics/top_elements_parser.rb', line 10 def parse @lines.each_with_index_and_catch do |line, index| element = initialize_element(line, 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 |