Class: Asciidoctor::Document::Title
- Inherits:
-
Object
- Object
- Asciidoctor::Document::Title
- Defined in:
- lib/asciidoctor/document.rb
Overview
Public Parsed and stores a partitioned title (i.e., title & subtitle).
Instance Attribute Summary collapse
- #combined ⇒ Object readonly
- #main ⇒ Object (also: #title) readonly
- #subtitle ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(val, opts = {}) ⇒ Title
constructor
A new instance of Title.
- #sanitized? ⇒ Boolean
- #subtitle? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(val, opts = {}) ⇒ Title
Returns a new instance of Title.
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/asciidoctor/document.rb', line 113 def initialize val, opts = {} # TODO separate sanitization by type (:cdata for HTML/XML, :plain_text for non-SGML, false for none) if (@sanitized = opts[:sanitize]) && val.include?('<') val = val.gsub(XmlSanitizeRx, '').squeeze(' ').strip end if (sep = opts[:separator] || ':').empty? || !val.include?(sep = %(#{sep} )) @main = val @subtitle = nil else @main, _, @subtitle = val.rpartition sep end @combined = val end |
Instance Attribute Details
#combined ⇒ Object (readonly)
111 112 113 |
# File 'lib/asciidoctor/document.rb', line 111 def combined @combined end |
#main ⇒ Object (readonly) Also known as: title
108 109 110 |
# File 'lib/asciidoctor/document.rb', line 108 def main @main end |
#subtitle ⇒ Object (readonly)
110 111 112 |
# File 'lib/asciidoctor/document.rb', line 110 def subtitle @subtitle end |
Instance Method Details
#sanitized? ⇒ Boolean
127 128 129 |
# File 'lib/asciidoctor/document.rb', line 127 def sanitized? @sanitized end |
#subtitle? ⇒ Boolean
131 132 133 |
# File 'lib/asciidoctor/document.rb', line 131 def subtitle? @subtitle ? true : false end |
#to_s ⇒ Object
135 136 137 |
# File 'lib/asciidoctor/document.rb', line 135 def to_s @combined end |