Class: Coradoc::AsciiDoc::Model::TextElement
- Inherits:
-
Base
- Object
- Lutaml::Model::Serializable
- Base
- Coradoc::AsciiDoc::Model::TextElement
- Defined in:
- lib/coradoc/asciidoc/model/text_element.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #inline? ⇒ Boolean
-
#text ⇒ String
Alias for text to work with ContentList.
-
#to_s ⇒ String
Get text content as string.
Methods inherited from Base
#block_level?, #serialize_content, #simplify_block_content, #to_adoc, #to_h, visit, #visit
Class Method Details
.escape_keychars(string) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/coradoc/asciidoc/model/text_element.rb', line 21 def self.escape_keychars(string) subs = { '*' => '\*', '_' => '\_' } string .gsub(/((?<=\s)[*_]+)|[*_]+(?=\s)/) do |n| n.chars.map do |char| subs[char] end.join end end |
Instance Method Details
#inline? ⇒ Boolean
7 8 9 |
# File 'lib/coradoc/asciidoc/model/text_element.rb', line 7 def inline? true end |
#text ⇒ String
Alias for text to work with ContentList
60 61 62 |
# File 'lib/coradoc/asciidoc/model/text_element.rb', line 60 def text to_s end |
#to_s ⇒ String
Get text content as string
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/coradoc/asciidoc/model/text_element.rb', line 35 def to_s case content when String content when Array content.map(&:to_s).join when Coradoc::AsciiDoc::Model::Base content.to_adoc when Lutaml::Model::Serializable if content.class.attributes.key?(:content) content.content.to_s else '' end when nil '' else content.is_a?(String) ? content.to_s : '' end end |