Class: MarkdownMetrics::Elements::Sentence::Bold

Inherits:
Base
  • Object
show all
Defined in:
lib/markdown_metrics/elements/sentence/bold.rb

Instance Attribute Summary

Attributes inherited from Base

#skip_lines_until

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attributes, #initialize

Constructor Details

This class inherits a constructor from MarkdownMetrics::Elements::Sentence::Base

Class Method Details

.match_element(character, next_character) ⇒ Object



7
8
9
# File 'lib/markdown_metrics/elements/sentence/bold.rb', line 7

def self.match_element(character, next_character)
  character.to_s == '*' && next_character.to_s == '*'
end

Instance Method Details

#nameObject



11
12
13
# File 'lib/markdown_metrics/elements/sentence/bold.rb', line 11

def name
  :bold
end

#valueObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/markdown_metrics/elements/sentence/bold.rb', line 15

def value
  final_value = nil

  @value.each_character_with_index_from(@start_at + 2) do |chr2, index2|
    next unless @value[index2..(index2 + 1)] == '**'

    final_value = @value[@start_at + 2..(index2 - 1)]
    @skip_lines_until = index2 + 1
    break
  end

  final_value
end