Class: MarkdownMetrics::Elements::Sentence::Italic

Inherits:
Base
  • Object
show all
Defined in:
lib/markdown_metrics/elements/sentence/italic.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/italic.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/italic.rb', line 11

def name
  :italic
end

#valueObject



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

def value
  final_value = nil

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

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

  final_value
end