Class: Strikethrough
- Inherits:
-
BasicToken
- Object
- BasicToken
- Strikethrough
- Extended by:
- Shared::InlineTokens
- Defined in:
- lib/rosetta/tokens/strikethrough.rb
Overview
Handles logic for Strikethrough tokens
Constant Summary collapse
- DELIMITER_TOKEN =
'~~'
Constants inherited from BasicToken
BasicToken::INLINE_CLASS_NAMES, BasicToken::TOP_LEVEL_CLASS_NAMES
Instance Attribute Summary
Attributes inherited from BasicToken
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Shared::InlineTokens
consume, delimiter_length, delimiter_token, matches?, valid_delimiter?
Methods inherited from BasicToken
#accept, #initialize, #inline?, #node_representation, #to_s
Constructor Details
This class inherits a constructor from BasicToken
Class Method Details
.consume(raw_text) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rosetta/tokens/strikethrough.rb', line 12 def self.consume(raw_text) # Add an extra 1 to offset the extra delimiter length (because strikethrough). delimiter_index = raw_text[delimiter_length..].index(DELIMITER_TOKEN) + delimiter_length + 1 source = raw_text[0..delimiter_index] new(source) end |
Instance Method Details
#type ⇒ Object
20 21 22 |
# File 'lib/rosetta/tokens/strikethrough.rb', line 20 def type :STRIKETHROUGH end |
#value ⇒ Object
24 25 26 27 28 |
# File 'lib/rosetta/tokens/strikethrough.rb', line 24 def value return DELIMITER_TOKEN * 2 if @source_text == DELIMITER_TOKEN * 2 @source_text[self.class.delimiter_length...-self.class.delimiter_length] end |